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()));
...
}