@@ -1338,29 +1338,33 @@ func (handler *InoHandler) cpp2inoTextEdit(cppURI lsp.DocumentURI, cppEdit lsp.T
1338
1338
return inoURI , inoEdit , err
1339
1339
}
1340
1340
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
1344
1346
}
1345
1347
1346
1348
inoSymbols := []lsp.DocumentSymbol {}
1347
- for _ , symbol := range origSymbols {
1349
+ for _ , symbol := range cppSymbols {
1350
+ log .Printf (" > convert %s %s" , symbol .Kind , symbol .Range )
1348
1351
if handler .sketchMapper .IsPreprocessedCppLine (symbol .Range .Start .Line ) {
1352
+ log .Printf (" symbol is in the preprocessed section of the sketch.ino.cpp" )
1349
1353
continue
1350
1354
}
1351
1355
1352
1356
inoFile , inoRange := handler .sketchMapper .CppToInoRange (symbol .Range )
1353
1357
inoSelectionURI , inoSelectionRange := handler .sketchMapper .CppToInoRange (symbol .SelectionRange )
1354
1358
1355
1359
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 )
1359
1363
continue
1360
1364
}
1361
1365
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 )
1364
1368
continue
1365
1369
}
1366
1370
@@ -1371,7 +1375,7 @@ func (handler *InoHandler) cpp2inoDocumentSymbols(origSymbols []lsp.DocumentSymb
1371
1375
Kind : symbol .Kind ,
1372
1376
Range : inoRange ,
1373
1377
SelectionRange : inoSelectionRange ,
1374
- Children : handler .cpp2inoDocumentSymbols (symbol .Children , origURI ),
1378
+ Children : handler .cpp2inoDocumentSymbols (symbol .Children , inoRequestedURI ),
1375
1379
})
1376
1380
}
1377
1381
0 commit comments