vscode: executeDocumentSymbolProvider no longer returns full (flat) list (Insiders)

In current stable, the executeDocumentSymbolProvider command returns a flat list of symbols (as SymbolInformation) even when the provider gives them as a tree of DocumentSymbol. In Insiders, as far as I can tell we only get back the top-level results but they still claim to be SymbolInformation.

If I inspect the values, they do seem to have the children in the underlying objects, but they seem to be typed as SymbolInformation which has no children property:

const a = await vs.commands.executeCommand("vscode.executeDocumentSymbolProvider", currentDoc().uri);

a[0] instanceof vs.DocumentSymbol
false
a[0] instanceof vs.SymbolInformation
true
a[0].children
Array(11) [r, r, r, r, r, r, r, r, …]

I’m not sure what the correct way is for me to enumerate these. Should they be returned as DocumentSymbols?

@jrieken Maybe slightly related to https://github.com/Microsoft/vscode/issues/52874#issuecomment-400215870. Should instanceof vs.DocumentSymbol here be returning true?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (11 by maintainers)

Most upvoted comments

Sorry, I was unaware that these methods were unsupported. That was not made at all clear from the documentation. Full disclaimer: I did not write the original code that used those APIs.

Anyway I think we’ll have to agree to disagree about “trust”. In my opinion: since all code can have bugs, it is always important to test that other peoples’ software works with yours. In fact, such testing is especially important because issues with dependencies are more likely to go unnoticed, but as a developer I am still responsible for making sure that my product as a whole works as expected, rather than just the parts that I write. My code working as expected is not enough; any issue with a dependency will also affect my product. I cannot rely on other peoples’ code to be bug-free; almost no code is ever bug-free, no matter how well written; and bugs in code I use can cause bugs in my software. Therefore it is vitally important to do UI/E2E testing in order to ensure that things actually work in practice. For instance, if VS Code were to ship a stable version that crashed because of a bug in Chromium, it would still be Microsoft’s problem to fix and roll back the changes until they are fixed. This is just my opinion.