Skip to content

Commit 98bbd42

Browse files
committed
Fixed synchronization problem with clangd
clangd/clangd#717 (comment)
1 parent ff7d9bd commit 98bbd42

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: ls/ls.go

+8
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,14 @@ func (ls *INOLanguageServer) ino2cppTextDocumentItem(logger jsonrpc.FunctionLogg
12961296
}
12971297

12981298
func (ls *INOLanguageServer) didChange(logger jsonrpc.FunctionLogger, inoDidChangeParams *lsp.DidChangeTextDocumentParams) (*lsp.DidChangeTextDocumentParams, error) {
1299+
// Clear all RangeLengths: it's a deprecated field and if the byte count is wrong the
1300+
// source text file will be unloaded from clangd without notice, leading to a "non-added
1301+
// docuemtn" error for all subsequent requests.
1302+
// https://github.com/clangd/clangd/issues/717#issuecomment-793220007
1303+
for i := range inoDidChangeParams.ContentChanges {
1304+
inoDidChangeParams.ContentChanges[i].RangeLength = nil
1305+
}
1306+
12991307
inoDoc := inoDidChangeParams.TextDocument
13001308

13011309
// Apply the change to the tracked sketch file.

0 commit comments

Comments
 (0)