From 32001ed925ee8b787cb41a62f009282aaf29072d Mon Sep 17 00:00:00 2001 From: Henning Dieterichs Date: Mon, 11 Apr 2022 10:51:29 +0200 Subject: [PATCH] Fixes bugs in bracket guides for wrapped lines. --- src/vs/editor/common/model/guidesTextModelPart.ts | 1 - src/vs/editor/common/textModelGuides.ts | 5 ++++- src/vs/editor/common/viewModel/viewModelLines.ts | 10 +++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/vs/editor/common/model/guidesTextModelPart.ts b/src/vs/editor/common/model/guidesTextModelPart.ts index 5a9366b5d992..9e7937f7ad61 100644 --- a/src/vs/editor/common/model/guidesTextModelPart.ts +++ b/src/vs/editor/common/model/guidesTextModelPart.ts @@ -416,7 +416,6 @@ export class GuidesTextModelPart extends TextModelPart implements IGuidesTextMod className, null, l === start.lineNumber ? start.column : -1, - // TODO: Investigate if this is correct l === end.lineNumber ? end.column : -1 ) ); diff --git a/src/vs/editor/common/textModelGuides.ts b/src/vs/editor/common/textModelGuides.ts index 7b63ee6b4d11..01789ed6b0cd 100644 --- a/src/vs/editor/common/textModelGuides.ts +++ b/src/vs/editor/common/textModelGuides.ts @@ -52,8 +52,11 @@ export class IndentGuide { * It starts at visibleColumn and continues until endColumn. */ public readonly horizontalLine: IndentGuideHorizontalLine | null, + /** + * If set (!= -1), only show this guide for wrapped lines that don't contain this model column, but are after it. + */ public readonly forWrappedLinesAfterColumn: number | -1, - public readonly forWrappedLinesBeforeColumn: number | -1 + public readonly forWrappedLinesBeforeOrAtColumn: number | -1 ) { if ((visibleColumn !== -1) === (column !== -1)) { throw new Error(); diff --git a/src/vs/editor/common/viewModel/viewModelLines.ts b/src/vs/editor/common/viewModel/viewModelLines.ts index 31d5e91de7f0..f2cb108acedd 100644 --- a/src/vs/editor/common/viewModel/viewModelLines.ts +++ b/src/vs/editor/common/viewModel/viewModelLines.ts @@ -582,10 +582,6 @@ export class ViewModelLinesFromProjectedModel implements IViewModelLines { // visibleColumns stay as they are (this is a bug and needs to be fixed, but it is not a regression) // model-columns must be converted to view-model columns. const result = bracketGuides.map(g => { - /*if (g.onlyForWrappedLines && !viewLineInfo.isWrappedLineContinuation) { - return undefined; - }*/ - if (g.forWrappedLinesAfterColumn !== -1) { const p = this.modelLineProjections[viewLineInfo.modelLineNumber - 1].getViewPositionOfModelPosition(0, g.forWrappedLinesAfterColumn); if (p.lineNumber >= viewLineInfo.modelLineWrappedLineIdx) { @@ -593,9 +589,9 @@ export class ViewModelLinesFromProjectedModel implements IViewModelLines { } } - if (g.forWrappedLinesBeforeColumn !== -1) { - const p = this.modelLineProjections[viewLineInfo.modelLineNumber - 1].getViewPositionOfModelPosition(0, g.forWrappedLinesBeforeColumn); - if (p.lineNumber <= viewLineInfo.modelLineWrappedLineIdx) { + if (g.forWrappedLinesBeforeOrAtColumn !== -1) { + const p = this.modelLineProjections[viewLineInfo.modelLineNumber - 1].getViewPositionOfModelPosition(0, g.forWrappedLinesBeforeOrAtColumn); + if (p.lineNumber < viewLineInfo.modelLineWrappedLineIdx) { return undefined; } }