mirror of
https://github.com/golang/go.git
synced 2025-05-06 08:03:03 +00:00
internal/lsp: fix incremental updates and turn them on
Updates that only add text have a start and end that are the same, we were erroring on those and failing to apply the changes. Fixes golang/go#31800 Change-Id: Ia31b90f108742e5532d2da35137c347c26090a6a Reviewed-on: https://go-review.googlesource.com/c/tools/+/174949 Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
490d13020f
commit
cf84161cff
@ -29,9 +29,13 @@ func (s *Server) initialize(ctx context.Context, params *protocol.InitializePara
|
|||||||
}
|
}
|
||||||
s.isInitialized = true // mark server as initialized now
|
s.isInitialized = true // mark server as initialized now
|
||||||
|
|
||||||
// TODO(rstambler): Change this default to protocol.Incremental (or add a
|
// TODO(iancottrell): Change this default to protocol.Incremental and remove the option
|
||||||
// flag). Disabled for now to simplify debugging.
|
|
||||||
s.textDocumentSyncKind = protocol.Full
|
s.textDocumentSyncKind = protocol.Full
|
||||||
|
if opts, ok := params.InitializationOptions.(map[string]interface{}); ok {
|
||||||
|
if opt, ok := opts["incrementalSync"].(bool); ok && opt {
|
||||||
|
s.textDocumentSyncKind = protocol.Incremental
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
s.setClientCapabilities(params.Capabilities)
|
s.setClientCapabilities(params.Capabilities)
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ func (s *Server) applyChanges(ctx context.Context, params *protocol.DidChangeTex
|
|||||||
return "", jsonrpc2.NewErrorf(jsonrpc2.CodeInternalError, "invalid range for content change")
|
return "", jsonrpc2.NewErrorf(jsonrpc2.CodeInternalError, "invalid range for content change")
|
||||||
}
|
}
|
||||||
start, end := spn.Start().Offset(), spn.End().Offset()
|
start, end := spn.Start().Offset(), spn.End().Offset()
|
||||||
if end <= start {
|
if end < start {
|
||||||
return "", jsonrpc2.NewErrorf(jsonrpc2.CodeInternalError, "invalid range for content change")
|
return "", jsonrpc2.NewErrorf(jsonrpc2.CodeInternalError, "invalid range for content change")
|
||||||
}
|
}
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user