Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/vs
diff options
context:
space:
mode:
authorAiday Marlen Kyzy <t-aidaym@microsoft.com>2022-07-27 17:53:03 +0300
committerGitHub <noreply@github.com>2022-07-27 17:53:03 +0300
commitc12aa6da6fca058af60a9d5e7419d7ff763a7df6 (patch)
tree212a45f5546dd8926c7392c0fbe07efc7a2930df /src/vs
parent079c49ed1277fc42d8a49823dc6fbab473223503 (diff)
parent878271b95f78398ca807a70e5f8ae888977494f6 (diff)
Merge pull request #156430 from aiday-mar/aiday/semanticScroll
Rerender the sticky scroll upon change of model tokens (fixes #156266)
Diffstat (limited to 'src/vs')
-rw-r--r--src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts32
1 files changed, 32 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..002828096d5 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,31 @@ 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 _needsUpdate(event: IModelTokensChangedEvent) {
+ const stickyLineNumbers = this.stickyScrollWidget.getCurrentLines();
+ for (const stickyLineNumber of stickyLineNumbers) {
+ for (const range of event.ranges) {
+ if (stickyLineNumber >= range.fromLineNumber && stickyLineNumber <= range.toLineNumber) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private _onTokensChange(event: IModelTokensChangedEvent) {
+ if (this._needsUpdate(event)) {
+ this._update(false);
+ }
+ }
+
private async _update(updateOutline: boolean = false): Promise<void> {
if (updateOutline) {
this._cts?.dispose(true);
@@ -235,6 +255,10 @@ class StickyScrollCodeLine {
this.effectiveLineHeight = this._editor.getOption(EditorOption.lineHeight) + this._relativePosition;
}
+ get lineNumber() {
+ return this._lineNumber;
+ }
+
getDomNode() {
const root: HTMLElement = document.createElement('div');
@@ -347,6 +371,14 @@ class StickyScrollWidget implements IOverlayWidget {
return this.arrayOfCodeLines.length;
}
+ getCurrentLines(): number[] {
+ const widgetLineRange: number[] = [];
+ for (const codeLine of this.arrayOfCodeLines) {
+ widgetLineRange.push(codeLine.lineNumber);
+ }
+ return widgetLineRange;
+ }
+
pushCodeLine(codeLine: StickyScrollCodeLine) {
this.arrayOfCodeLines.push(codeLine);
}