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-28 19:50:59 +0300
committerGitHub <noreply@github.com>2022-07-28 19:50:59 +0300
commit78f402334ca2ec69d0ac8404a02651553f038c1b (patch)
treed03472d851ebba4bd58921e5c676f8329ec6682a /src/vs
parente45b7a5a426802fb475b3a0856b80b313f2c9411 (diff)
parentbd9ff90a64cd0208d260ba18e71e3cf02232e128 (diff)
Merge pull request #156578 from aiday-mar/aiday/semanticScroll
Filtering the ranges with the hidden ranges from folding. Fixes #156268.
Diffstat (limited to 'src/vs')
-rw-r--r--src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts b/src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts
index 899d3db5fc6..c42d96dff27 100644
--- a/src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts
+++ b/src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts
@@ -19,6 +19,7 @@ import { LineDecoration } from 'vs/editor/common/viewLayout/lineDecorations';
import { RunOnceScheduler } from 'vs/base/common/async';
import { IModelTokensChangedEvent } from 'vs/editor/common/textModelEvents';
import { Position } from 'vs/editor/common/core/position';
+import { Range } from 'vs/editor/common/core/range';
class StickyScrollController extends Disposable implements IEditorContribution {
@@ -61,6 +62,7 @@ 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.onDidChangeHiddenAreas(() => this._update(true)));
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)));
@@ -92,6 +94,12 @@ class StickyScrollController extends Disposable implements IEditorContribution {
this._cts = new CancellationTokenSource();
await this._updateOutlineModel(this._cts.token);
}
+ const hiddenRanges: Range[] | undefined = this._editor._getViewModel()?.getHiddenAreas();
+ if (hiddenRanges) {
+ for (const hiddenRange of hiddenRanges) {
+ this._ranges = this._ranges.filter(range => { return !(range[0] >= hiddenRange.startLineNumber && range[1] <= hiddenRange.endLineNumber + 1); });
+ }
+ }
this._renderStickyScroll();
}
@@ -202,12 +210,12 @@ 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(start, this._editor, -1, bottomOfEndLine - bottomOfElementAtDepth));
+ this.stickyScrollWidget.pushCodeLine(new StickyScrollCodeLine(start, depth, this._editor, -1, bottomOfEndLine - bottomOfElementAtDepth));
break;
}
- else if (bottomOfElementAtDepth > bottomOfBeginningLine - 1 && bottomOfElementAtDepth < bottomOfEndLine - 1) {
+ else if (bottomOfElementAtDepth > bottomOfBeginningLine && bottomOfElementAtDepth < bottomOfEndLine - 1) {
beginningLinesConsidered.add(start);
- this.stickyScrollWidget.pushCodeLine(new StickyScrollCodeLine(start, this._editor, 0, 0));
+ this.stickyScrollWidget.pushCodeLine(new StickyScrollCodeLine(start, depth, this._editor, 0, 0));
}
} else {
this._ranges.splice(index, 1);
@@ -229,7 +237,7 @@ class StickyScrollCodeLine {
public readonly effectiveLineHeight: number = 0;
- constructor(private readonly _lineNumber: number, private readonly _editor: IActiveCodeEditor,
+ constructor(private readonly _lineNumber: number, private readonly _depth: number, private readonly _editor: IActiveCodeEditor,
private readonly _zIndex: number, private readonly _relativePosition: number) {
this.effectiveLineHeight = this._editor.getOption(EditorOption.lineHeight) + this._relativePosition;
}
@@ -294,8 +302,9 @@ class StickyScrollCodeLine {
root.onclick = e => {
e.stopPropagation();
e.preventDefault();
- this._editor.revealLine(this._lineNumber);
+ this._editor.revealPosition({ lineNumber: this._lineNumber - this._depth + 1, column: 1 });
};
+
root.onmouseover = e => {
innerLineNumberHTML.style.background = `var(--vscode-editorStickyScrollHover-background)`;
lineHTMLNode.style.backgroundColor = `var(--vscode-editorStickyScrollHover-background)`;
@@ -345,7 +354,7 @@ class StickyScrollWidget implements IOverlayWidget {
constructor(public readonly _editor: ICodeEditor) {
this.rootDomNode = document.createElement('div');
this.rootDomNode.style.width = '100%';
- this.rootDomNode.style.boxShadow = `var(--vscode-scrollbar-shadow) 0 6px 6px -6px`; // '0px 0px 8px 2px #000000';
+ this.rootDomNode.style.boxShadow = `var(--vscode-scrollbar-shadow) 0 6px 6px -6px`;
}
get codeLineCount() {