From e9f17a5d77692de5f5050397f150ed6eb5fd7b54 Mon Sep 17 00:00:00 2001 From: Henning Dieterichs Date: Wed, 12 Jul 2023 12:13:46 +0200 Subject: [PATCH 1/2] Fixes #187063 --- src/vs/editor/browser/editorBrowser.ts | 6 ++++++ src/vs/editor/browser/widget/codeEditorWidget.ts | 4 ++++ src/vs/editor/common/model/tokenizationTextModelPart.ts | 2 +- src/vs/monaco.d.ts | 5 +++++ .../contrib/files/browser/editors/textFileEditor.ts | 4 ++++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/vs/editor/browser/editorBrowser.ts b/src/vs/editor/browser/editorBrowser.ts index 2cd8aabfa0d..97752ae0bd5 100644 --- a/src/vs/editor/browser/editorBrowser.ts +++ b/src/vs/editor/browser/editorBrowser.ts @@ -1086,6 +1086,12 @@ export interface ICodeEditor extends editorCommon.IEditor { hasModel(): this is IActiveCodeEditor; setBanner(bannerDomNode: HTMLElement | null, height: number): void; + + /** + * Is called when the model has been set, view state was restored and options are updated. + * This is the best place to render UI. + */ + handleInitialized?(): void; } /** diff --git a/src/vs/editor/browser/widget/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditorWidget.ts index e90726fe00c..0903e174700 100644 --- a/src/vs/editor/browser/widget/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditorWidget.ts @@ -1021,6 +1021,10 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE } } + public handleInitialized(): void { + this._getViewModel()?.visibleLinesStabilized(); + } + public onVisible(): void { this._modelData?.view.refreshFocusState(); } diff --git a/src/vs/editor/common/model/tokenizationTextModelPart.ts b/src/vs/editor/common/model/tokenizationTextModelPart.ts index e077e75afe1..c203f53ad76 100644 --- a/src/vs/editor/common/model/tokenizationTextModelPart.ts +++ b/src/vs/editor/common/model/tokenizationTextModelPart.ts @@ -642,7 +642,7 @@ class AttachedViewHandler extends Disposable { } private update(): void { - if (equals(this._computedLineRanges, this._lineRanges)) { + if (equals(this._computedLineRanges, this._lineRanges, (a, b) => a.equals(b))) { return; } this._computedLineRanges = this._lineRanges; diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 9e2a863d592..60d3bd03976 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -6065,6 +6065,11 @@ declare namespace monaco.editor { */ applyFontInfo(target: HTMLElement): void; setBanner(bannerDomNode: HTMLElement | null, height: number): void; + /** + * Is called when the model has been set, view state was restored and options are updated. + * This is the best place to render UI. + */ + handleInitialized?(): void; } /** diff --git a/src/vs/workbench/contrib/files/browser/editors/textFileEditor.ts b/src/vs/workbench/contrib/files/browser/editors/textFileEditor.ts index 438accb72ad..44dc610e936 100644 --- a/src/vs/workbench/contrib/files/browser/editors/textFileEditor.ts +++ b/src/vs/workbench/contrib/files/browser/editors/textFileEditor.ts @@ -148,6 +148,10 @@ export class TextFileEditor extends AbstractTextCodeEditor // a resolved model might have more specific information about being // readonly or not that the input did not have. control.updateOptions(this.getReadonlyConfiguration(textFileModel.isReadonly())); + + if (control.handleInitialized) { + control.handleInitialized(); + } } catch (error) { await this.handleSetInputError(error, input, options); } From 16098b1fe1936f7f8c31d2ae655f6f88dc6fbf42 Mon Sep 17 00:00:00 2001 From: Henning Dieterichs Date: Wed, 12 Jul 2023 12:31:31 +0200 Subject: [PATCH 2/2] Updates comment --- src/vs/editor/browser/editorBrowser.ts | 2 +- src/vs/monaco.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/editor/browser/editorBrowser.ts b/src/vs/editor/browser/editorBrowser.ts index 97752ae0bd5..4d6c57410be 100644 --- a/src/vs/editor/browser/editorBrowser.ts +++ b/src/vs/editor/browser/editorBrowser.ts @@ -1089,7 +1089,7 @@ export interface ICodeEditor extends editorCommon.IEditor { /** * Is called when the model has been set, view state was restored and options are updated. - * This is the best place to render UI. + * This is the best place to compute data for the viewport (such as tokens). */ handleInitialized?(): void; } diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 60d3bd03976..770c1268f3a 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -6067,7 +6067,7 @@ declare namespace monaco.editor { setBanner(bannerDomNode: HTMLElement | null, height: number): void; /** * Is called when the model has been set, view state was restored and options are updated. - * This is the best place to render UI. + * This is the best place to compute data for the viewport (such as tokens). */ handleInitialized?(): void; }