Skip to content

Commit 9a2f95b

Browse files
committed
Parser cancellation errors now swallowed
1 parent 6d70c5f commit 9a2f95b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

server/src/project/workspace.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { LanguageServerConfiguration } from '../server';
2828
import { hasConfigurationCapability } from '../capabilities/workspaceFolder';
2929
import { sleep } from '../utils/helpers';
3030
import { 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
}

0 commit comments

Comments
 (0)