Fixes #135726 by properly skipping unbalanced bracket pairs when rendering bracket pair guides.

上级 f1343b2a
......@@ -3098,9 +3098,7 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
endLineNumber,
this.getLineMaxColumn(endLineNumber)
)
)
// Exclude bracket pairs that are not balanced.
.filter(b => b.closingBracketRange !== undefined);
);
let activeBracketPairRange: Range | undefined = undefined;
if (activePosition && bracketPairs.length > 0) {
......@@ -3136,7 +3134,7 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
visibleEndColumn: number,
bracketPair: BracketPairInfo,
renderHorizontalEndLineAtTheBottom: boolean
}>();
} | null>();
const nextGuides = new Array<model.IndentGuide>();
const colorProvider = new BracketPairGuidesClassNames();
......@@ -3169,6 +3167,13 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
// TODO: Consider indentation when computing guideVisibleColumn
const start = pair.openingBracketRange.getStartPosition();
const end = (pair.closingBracketRange?.getStartPosition() ?? pair.range.getEndPosition());
if (pair.closingBracketRange === undefined) {
// Don't show guides for bracket pairs that are not balanced.
// See #135125.
activeGuides[pair.nestingLevel] = null;
} else {
activeGuides[pair.nestingLevel] = {
nestingLevel: pair.nestingLevel,
guideVisibleColumn,
......@@ -3180,8 +3185,12 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
renderHorizontalEndLineAtTheBottom
};
}
}
for (const line of activeGuides) {
if (!line) {
continue;
}
const isActive = activeBracketPairRange && line.bracketPair.range.equalsRange(activeBracketPairRange);
const className =
......@@ -3214,7 +3223,9 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
// Going backwards, so the last guide potentially replaces others
for (let i = activeGuides.length - 1; i >= 0; i--) {
const line = activeGuides[i];
if (!line) {
continue;
}
const isActive = options.highlightActive && activeBracketPairRange &&
line.bracketPair.range.equalsRange(activeBracketPairRange);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册