File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import { LanguageServerConfiguration } from '../server';
2828import { hasConfigurationCapability } from '../capabilities/workspaceFolder' ;
2929import { sleep } from '../utils/helpers' ;
3030import { NamespaceManager } from './scope' ;
31+ import { ParseCancellationException } from 'antlr4ng' ;
3132
3233
3334/**
@@ -263,7 +264,16 @@ class WorkspaceEvents {
263264 }
264265
265266 private async onFoldingRangesAsync ( params : FoldingRangeParams , token : CancellationToken ) : Promise < FoldingRange [ ] > {
266- const document = await this . getParsedDocument ( params . textDocument . uri , 0 , token ) ;
267+ let document : BaseProjectDocument | undefined ;
268+ try {
269+ document = await this . getParsedDocument ( params . textDocument . uri , 0 , token ) ;
270+ } catch ( error ) {
271+ // Swallow parser cancellations and rethrow anything else.
272+ if ( ! ! ( error instanceof ParseCancellationException ) ) {
273+ throw error ;
274+ }
275+ // this.workspace.connection.window.showInformationMessage(`Parser error: ${error}`);
276+ }
267277 const result = document ?. languageServerFoldingRanges ( ) ;
268278 return result ?? [ ] ;
269279 }
You can’t perform that action at this time.
0 commit comments