1

My question is about code folding in VSCODE editor. I wonder if it is possible to base code folding upon symbols defined?

I have created an extension that finds all the symbols in a file to make it possible to navigate to these symbols. Now I would like to base my code folding on the range of these symbols. Is this possible?

In my extension I have implemented something similar to this example to find all symbols and their ranges.

DIRECT IMPLEMENTATION

class GoDocumentSymbolProvider implements vscode.DocumentSymbolProvider {
    public provideDocumentSymbols(
        document: vscode.TextDocument, token: vscode.CancellationToken):
        Thenable<vscode.SymbolInformation[]> {
    ...
    }
}

export function activate(ctx: vscode.ExtensionContext): void {
    ...
    ctx.subscriptions.push(
        vscode.languages.registerDocumentSymbolProvider(
            GO_MODE, new GoDocumentSymbolProvider()));
    ...
}
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
haarse
  • 39
  • 4
  • I think this will be possible soon. Maybe this [**proposed** api](https://code.visualstudio.com/updates/v1_21#_folding) does what you want? – HaaLeo Mar 19 '18 at 10:22

0 Answers0