diff options
author | aiday-mar <t-aidaym@microsoft.com> | 2022-07-27 15:49:17 +0300 |
---|---|---|
committer | aiday-mar <t-aidaym@microsoft.com> | 2022-07-27 15:49:30 +0300 |
commit | ff3a45d5be9dc9757b24e701d61b390e37fad865 (patch) | |
tree | d11e5ec29ec716597ee889eed1baa36b034558a2 /src/vs | |
parent | 45e0ad107ab50573c8c089338ee10d65aa3889fc (diff) |
Calls onDidChangeModelTokens and updates when the range of update intersects with the line range of the sticky scroll widget
Diffstat (limited to 'src/vs')
-rw-r--r-- | src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts b/src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts index 7d9cbf358ed..183314bb276 100644 --- a/src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts +++ b/src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts @@ -17,6 +17,7 @@ import { RenderLineInput, renderViewLine } from 'vs/editor/common/viewLayout/vie import { SymbolKind } from 'vs/editor/common/languages'; import { LineDecoration } from 'vs/editor/common/viewLayout/lineDecorations'; import { RunOnceScheduler } from 'vs/base/common/async'; +import { IModelTokensChangedEvent } from 'vs/editor/common/textModelEvents'; const enum ScrollDirection { Down = 0, @@ -66,12 +67,24 @@ class StickyScrollController extends Disposable implements IEditorContribution { this._editor.addOverlayWidget(this.stickyScrollWidget); this._sessionStore.add(this._editor.onDidChangeModel(() => this._update(true))); this._sessionStore.add(this._editor.onDidScrollChange(() => this._update(false))); + this._sessionStore.add(this._editor.onDidChangeModelTokens((e) => this._onTokensChange(e))); this._sessionStore.add(this._editor.onDidChangeModelContent(() => this._updateSoon.schedule())); this._sessionStore.add(this._languageFeaturesService.documentSymbolProvider.onDidChange(() => this._update(true))); this._update(true); } } + private _onTokensChange(event: IModelTokensChangedEvent) { + const beginningLine = this._editor.getVisibleRanges()[0].getStartPosition().lineNumber - 1; + const endLine = beginningLine + this.stickyScrollWidget.codeLineCount + 1; + const fromLineNumber = event.ranges[0].fromLineNumber; + const toLineNumber = event.ranges[0].toLineNumber; + if (fromLineNumber > endLine || beginningLine > toLineNumber) { + return; + } + this._update(false); + } + private async _update(updateOutline: boolean = false): Promise<void> { if (updateOutline) { this._cts?.dispose(true); |