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-mar <t-aidaym@microsoft.com>2022-07-27 16:41:27 +0300
committeraiday-mar <t-aidaym@microsoft.com>2022-07-27 16:41:36 +0300
commit2ad2cd4e718dd3b292cd423921bcccd371f2c4f0 (patch)
tree55fb74c70a8b6f5e570e8891fb18f39192c070c0 /src/vs
parent4cab11e346d7ffddab53728aa94503b2fa068fa4 (diff)
Iterating over all the ranges in the onDidChangeModelTokens function
Diffstat (limited to 'src/vs')
-rw-r--r--src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts b/src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts
index 183314bb276..0da33b17f98 100644
--- a/src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts
+++ b/src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts
@@ -75,14 +75,21 @@ class StickyScrollController extends Disposable implements IEditorContribution {
}
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;
+ const widgetLineRange = this.stickyScrollWidget.getCurrentLineRange();
+ let rerender: boolean = false;
+ for (const range of event.ranges) {
+ const fromLineNumber = range.fromLineNumber;
+ const toLineNumber = range.toLineNumber;
+ const fromLineWidget = widgetLineRange[0];
+ const toLineWidget = widgetLineRange[1];
+ if (fromLineNumber <= toLineWidget && toLineNumber >= fromLineWidget) {
+ rerender = true;
+ break;
+ }
+ }
+ if (rerender === true) {
+ this._update(false);
}
- this._update(false);
}
private async _update(updateOutline: boolean = false): Promise<void> {
@@ -212,16 +219,16 @@ class StickyScrollController extends Disposable implements IEditorContribution {
if (!beginningLinesConsidered.has(start)) {
if (topOfElementAtDepth >= topOfEndLine - 1 && topOfElementAtDepth < bottomOfEndLine - 2) {
beginningLinesConsidered.add(start);
- this.stickyScrollWidget.pushCodeLine(new StickyScrollCodeLine(model.getLineContent(start), start, this._editor, -1, bottomOfEndLine - bottomOfElementAtDepth));
+ this.stickyScrollWidget.pushCodeLine(start, new StickyScrollCodeLine(model.getLineContent(start), start, this._editor, -1, bottomOfEndLine - bottomOfElementAtDepth));
break;
}
else if (scrollDirection === ScrollDirection.Down && bottomOfElementAtDepth > bottomOfBeginningLine - 1 && bottomOfElementAtDepth < bottomOfEndLine - 1) {
beginningLinesConsidered.add(start);
- this.stickyScrollWidget.pushCodeLine(new StickyScrollCodeLine(model.getLineContent(start), start, this._editor, 0, 0));
+ this.stickyScrollWidget.pushCodeLine(start, new StickyScrollCodeLine(model.getLineContent(start), start, this._editor, 0, 0));
} else if (scrollDirection === ScrollDirection.Up && scrollToBottomOfWidget > bottomOfBeginningLine - 1 && scrollToBottomOfWidget < bottomOfEndLine ||
scrollDirection === ScrollDirection.Up && bottomOfElementAtDepth > bottomOfBeginningLine && bottomOfElementAtDepth < topOfEndLine - 1) {
beginningLinesConsidered.add(start);
- this.stickyScrollWidget.pushCodeLine(new StickyScrollCodeLine(model.getLineContent(start), start, this._editor, 0, 0));
+ this.stickyScrollWidget.pushCodeLine(start, new StickyScrollCodeLine(model.getLineContent(start), start, this._editor, 0, 0));
}
} else {
this._ranges.splice(index, 1);
@@ -348,6 +355,7 @@ class StickyScrollCodeLine {
class StickyScrollWidget implements IOverlayWidget {
private readonly arrayOfCodeLines: StickyScrollCodeLine[] = [];
+ private readonly linesRange: number[] = [];
private readonly rootDomNode: HTMLElement = document.createElement('div');
constructor(public readonly _editor: ICodeEditor) {
@@ -360,7 +368,15 @@ class StickyScrollWidget implements IOverlayWidget {
return this.arrayOfCodeLines.length;
}
- pushCodeLine(codeLine: StickyScrollCodeLine) {
+ getCurrentLineRange(): number[] {
+ const widgetLineRange = [];
+ widgetLineRange.push(this.linesRange[0]);
+ widgetLineRange.push(this.linesRange[this.linesRange.length - 1]);
+ return widgetLineRange;
+ }
+
+ pushCodeLine(codeLineNumber: number, codeLine: StickyScrollCodeLine) {
+ this.linesRange.push(codeLineNumber);
this.arrayOfCodeLines.push(codeLine);
}