Skip to content

Commit f1cf6ba

Browse files
committed
Fixed documentSymbol handling for Windows
1 parent 5dd3ea2 commit f1cf6ba

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

Diff for: handler/handler.go

+14-10
Original file line numberDiff line numberDiff line change
@@ -1338,29 +1338,33 @@ func (handler *InoHandler) cpp2inoTextEdit(cppURI lsp.DocumentURI, cppEdit lsp.T
13381338
return inoURI, inoEdit, err
13391339
}
13401340

1341-
func (handler *InoHandler) cpp2inoDocumentSymbols(origSymbols []lsp.DocumentSymbol, origURI lsp.DocumentURI) []lsp.DocumentSymbol {
1342-
if origURI.Ext() != ".ino" || len(origSymbols) == 0 {
1343-
return origSymbols
1341+
func (handler *InoHandler) cpp2inoDocumentSymbols(cppSymbols []lsp.DocumentSymbol, inoRequestedURI lsp.DocumentURI) []lsp.DocumentSymbol {
1342+
inoRequested := inoRequestedURI.Canonical()
1343+
log.Printf(" filtering for requested ino file: %s", inoRequested)
1344+
if inoRequestedURI.Ext() != ".ino" || len(cppSymbols) == 0 {
1345+
return cppSymbols
13441346
}
13451347

13461348
inoSymbols := []lsp.DocumentSymbol{}
1347-
for _, symbol := range origSymbols {
1349+
for _, symbol := range cppSymbols {
1350+
log.Printf(" > convert %s %s", symbol.Kind, symbol.Range)
13481351
if handler.sketchMapper.IsPreprocessedCppLine(symbol.Range.Start.Line) {
1352+
log.Printf(" symbol is in the preprocessed section of the sketch.ino.cpp")
13491353
continue
13501354
}
13511355

13521356
inoFile, inoRange := handler.sketchMapper.CppToInoRange(symbol.Range)
13531357
inoSelectionURI, inoSelectionRange := handler.sketchMapper.CppToInoRange(symbol.SelectionRange)
13541358

13551359
if inoFile != inoSelectionURI {
1356-
log.Printf(" ERROR: symbol range and selection belongs to different URI!")
1357-
log.Printf(" > %s != %s", symbol.Range, symbol.SelectionRange)
1358-
log.Printf(" > %s:%s != %s:%s", inoFile, inoRange, inoSelectionURI, inoSelectionRange)
1360+
log.Printf(" ERROR: symbol range and selection belongs to different URI!")
1361+
log.Printf(" symbol %s != selection %s", symbol.Range, symbol.SelectionRange)
1362+
log.Printf(" %s:%s != %s:%s", inoFile, inoRange, inoSelectionURI, inoSelectionRange)
13591363
continue
13601364
}
13611365

1362-
if inoFile != origURI.Unbox() {
1363-
//log.Printf(" skipping symbol related to %s", inoFile)
1366+
if inoFile != inoRequested {
1367+
log.Printf(" skipping symbol related to %s", inoFile)
13641368
continue
13651369
}
13661370

@@ -1371,7 +1375,7 @@ func (handler *InoHandler) cpp2inoDocumentSymbols(origSymbols []lsp.DocumentSymb
13711375
Kind: symbol.Kind,
13721376
Range: inoRange,
13731377
SelectionRange: inoSelectionRange,
1374-
Children: handler.cpp2inoDocumentSymbols(symbol.Children, origURI),
1378+
Children: handler.cpp2inoDocumentSymbols(symbol.Children, inoRequestedURI),
13751379
})
13761380
}
13771381

0 commit comments

Comments
 (0)