@@ -42,7 +42,7 @@ type CLangdStarter func() (stdin io.WriteCloser, stdout io.ReadCloser, stderr io
4242func NewInoHandler (stdio io.ReadWriteCloser , board lsp.Board ) * InoHandler {
4343 handler := & InoHandler {
4444 data : map [lsp.DocumentURI ]* FileData {},
45- trackedFiles : map [lsp.DocumentURI ]lsp.TextDocumentItem {},
45+ trackedFiles : map [lsp.DocumentURI ]* lsp.TextDocumentItem {},
4646 config : lsp.BoardConfig {
4747 SelectedBoard : board ,
4848 },
@@ -70,11 +70,12 @@ type InoHandler struct {
7070 buildPath * paths.Path
7171 buildSketchRoot * paths.Path
7272 buildSketchCpp * paths.Path
73+ buildSketchCppVersion int
7374 sketchRoot * paths.Path
7475 sketchName string
7576 sketchMapper * sourcemapper.InoMapper
7677 sketchTrackedFilesCount int
77- trackedFiles map [lsp.DocumentURI ]lsp.TextDocumentItem
78+ trackedFiles map [lsp.DocumentURI ]* lsp.TextDocumentItem
7879
7980 data map [lsp.DocumentURI ]* FileData
8081 config lsp.BoardConfig
@@ -131,7 +132,7 @@ func (handler *InoHandler) HandleMessageFromIDE(ctx context.Context, conn *jsonr
131132 case * lsp.DidOpenTextDocumentParams :
132133 // method "textDocument/didOpen"
133134 uri = p .TextDocument .URI
134- log .Printf ("--> didOpen(%s)" , uri )
135+ log .Printf ("--> didOpen(%s@%d as '%s' )" , p . TextDocument . URI , p . TextDocument . Version , p . TextDocument . LanguageID )
135136
136137 handler .synchronizer .DataMux .Lock ()
137138 res , err := handler .didOpen (ctx , p )
@@ -142,7 +143,7 @@ func (handler *InoHandler) HandleMessageFromIDE(ctx context.Context, conn *jsonr
142143 return nil , err // do not propagate to clangd
143144 }
144145
145- log .Printf (" --> didOpen(%s)" , res .TextDocument .URI )
146+ log .Printf (" --> didOpen(%s@%d as '%s' )" , res .TextDocument .URI , res . TextDocument . Version , p . TextDocument . LanguageID )
146147 params = res
147148
148149 case * lsp.CompletionParams :
@@ -279,6 +280,7 @@ func (handler *InoHandler) initializeWorkbench(ctx context.Context, params *lsp.
279280 return err
280281 }
281282 handler .buildSketchCpp = handler .buildSketchRoot .Join (handler .sketchName + ".ino.cpp" )
283+ handler .buildSketchCppVersion = 1
282284
283285 if cppContent , err := handler .buildSketchCpp .ReadFile (); err == nil {
284286 handler .sketchMapper = sourcemapper .CreateInoMapper (cppContent )
@@ -351,7 +353,7 @@ func startClangd(compileCommandsDir, sketchCpp *paths.Path) (io.WriteCloser, io.
351353func (handler * InoHandler ) didOpen (ctx context.Context , params * lsp.DidOpenTextDocumentParams ) (* lsp.DidOpenTextDocumentParams , error ) {
352354 // Add the TextDocumentItem in the tracked files list
353355 doc := params .TextDocument
354- handler .trackedFiles [doc .URI ] = doc
356+ handler .trackedFiles [doc .URI ] = & doc
355357
356358 // If we are tracking a .ino...
357359 if doc .URI .AsPath ().Ext () == ".ino" {
@@ -366,7 +368,7 @@ func (handler *InoHandler) didOpen(ctx context.Context, params *lsp.DidOpenTextD
366368 URI : lsp .NewDocumenteURIFromPath (handler .buildSketchCpp ),
367369 Text : string (sketchCpp ),
368370 LanguageID : "cpp" ,
369- Version : 1 ,
371+ Version : handler . buildSketchCppVersion ,
370372 },
371373 }
372374 return newParam , err
0 commit comments