Skip to content

Commit

Permalink
Re #167719. Disable word highlighting, codelens, sticky provider when…
Browse files Browse the repository at this point in the history
… the model is very large. (#193055)
  • Loading branch information
rebornix authored Sep 13, 2023
1 parent d24d866 commit 17f32ea
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class CodeLensContribution implements IEditorContribution {
return;
}

if (!this._editor.getOption(EditorOption.codeLens)) {
if (!this._editor.getOption(EditorOption.codeLens) || model.isTooLargeForTokenization()) {
return;
}

Expand Down
4 changes: 4 additions & 0 deletions src/vs/editor/contrib/links/browser/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ export class LinkDetector extends Disposable implements IEditorContribution {

const model = this.editor.getModel();

if (model.isTooLargeForSyncing()) {
return;
}

if (!this.providers.has(model)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class StickyLineCandidateProvider extends Disposable implements IStickyLi

private async updateStickyModel(token: CancellationToken): Promise<void> {

if (!this._editor.hasModel() || !this._stickyModelProvider) {
if (!this._editor.hasModel() || !this._stickyModelProvider || this._editor.getModel().isTooLargeForTokenization()) {
this._model = null;
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ export class WordHighlighterContribution extends Disposable implements IEditorCo
this.wordHighlighter = null;
this.linkedContributions = new Set();
const createWordHighlighterIfPossible = () => {
if (editor.hasModel()) {
if (editor.hasModel() && !editor.getModel().isTooLargeForTokenization()) {
this.wordHighlighter = new WordHighlighter(editor, languageFeaturesService.documentHighlightProvider, () => Iterable.map(this.linkedContributions, c => c.wordHighlighter), contextKeyService);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class LargeFileOptimizationsWarner extends Disposable implements IEditorC
'Variable 0 will be a file name.'
]
},
"{0}: tokenization, wrapping, folding and sticky scroll have been turned off for this large file in order to reduce memory usage and avoid freezing or crashing.",
"{0}: tokenization, wrapping, folding, codelens, word highlighting and sticky scroll have been turned off for this large file in order to reduce memory usage and avoid freezing or crashing.",
path.basename(model.uri.path)
);

Expand Down

0 comments on commit 17f32ea

Please sign in to comment.