@@ -42,7 +42,7 @@ type CLangdStarter func() (stdin io.WriteCloser, stdout io.ReadCloser, stderr io
42
42
func NewInoHandler (stdio io.ReadWriteCloser , board lsp.Board ) * InoHandler {
43
43
handler := & InoHandler {
44
44
data : map [lsp.DocumentURI ]* FileData {},
45
- trackedFiles : map [lsp.DocumentURI ]lsp.TextDocumentItem {},
45
+ trackedFiles : map [lsp.DocumentURI ]* lsp.TextDocumentItem {},
46
46
config : lsp.BoardConfig {
47
47
SelectedBoard : board ,
48
48
},
@@ -70,11 +70,12 @@ type InoHandler struct {
70
70
buildPath * paths.Path
71
71
buildSketchRoot * paths.Path
72
72
buildSketchCpp * paths.Path
73
+ buildSketchCppVersion int
73
74
sketchRoot * paths.Path
74
75
sketchName string
75
76
sketchMapper * sourcemapper.InoMapper
76
77
sketchTrackedFilesCount int
77
- trackedFiles map [lsp.DocumentURI ]lsp.TextDocumentItem
78
+ trackedFiles map [lsp.DocumentURI ]* lsp.TextDocumentItem
78
79
79
80
data map [lsp.DocumentURI ]* FileData
80
81
config lsp.BoardConfig
@@ -131,7 +132,7 @@ func (handler *InoHandler) HandleMessageFromIDE(ctx context.Context, conn *jsonr
131
132
case * lsp.DidOpenTextDocumentParams :
132
133
// method "textDocument/didOpen"
133
134
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 )
135
136
136
137
handler .synchronizer .DataMux .Lock ()
137
138
res , err := handler .didOpen (ctx , p )
@@ -142,7 +143,7 @@ func (handler *InoHandler) HandleMessageFromIDE(ctx context.Context, conn *jsonr
142
143
return nil , err // do not propagate to clangd
143
144
}
144
145
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 )
146
147
params = res
147
148
148
149
case * lsp.CompletionParams :
@@ -279,6 +280,7 @@ func (handler *InoHandler) initializeWorkbench(ctx context.Context, params *lsp.
279
280
return err
280
281
}
281
282
handler .buildSketchCpp = handler .buildSketchRoot .Join (handler .sketchName + ".ino.cpp" )
283
+ handler .buildSketchCppVersion = 1
282
284
283
285
if cppContent , err := handler .buildSketchCpp .ReadFile (); err == nil {
284
286
handler .sketchMapper = sourcemapper .CreateInoMapper (cppContent )
@@ -351,7 +353,7 @@ func startClangd(compileCommandsDir, sketchCpp *paths.Path) (io.WriteCloser, io.
351
353
func (handler * InoHandler ) didOpen (ctx context.Context , params * lsp.DidOpenTextDocumentParams ) (* lsp.DidOpenTextDocumentParams , error ) {
352
354
// Add the TextDocumentItem in the tracked files list
353
355
doc := params .TextDocument
354
- handler .trackedFiles [doc .URI ] = doc
356
+ handler .trackedFiles [doc .URI ] = & doc
355
357
356
358
// If we are tracking a .ino...
357
359
if doc .URI .AsPath ().Ext () == ".ino" {
@@ -366,7 +368,7 @@ func (handler *InoHandler) didOpen(ctx context.Context, params *lsp.DidOpenTextD
366
368
URI : lsp .NewDocumenteURIFromPath (handler .buildSketchCpp ),
367
369
Text : string (sketchCpp ),
368
370
LanguageID : "cpp" ,
369
- Version : 1 ,
371
+ Version : handler . buildSketchCppVersion ,
370
372
},
371
373
}
372
374
return newParam , err
0 commit comments