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