Fixes #137225. The range of the active bracket pair must now strictly contain the cursor position.

This commit is contained in:
Henning Dieterichs
2021-11-23 10:56:18 +01:00
parent dc52700a60
commit b43aa6c4ea
2 changed files with 18 additions and 1 deletions
+17
View File
@@ -100,6 +100,23 @@ export class Range {
return true;
}
/**
* Test if `position` is in `range`. If the position is at the edges, will return false.
* @internal
*/
public static strictContainsPosition(range: IRange, position: IPosition): boolean {
if (position.lineNumber < range.startLineNumber || position.lineNumber > range.endLineNumber) {
return false;
}
if (position.lineNumber === range.startLineNumber && position.column <= range.startColumn) {
return false;
}
if (position.lineNumber === range.endLineNumber && position.column >= range.endColumn) {
return false;
}
return true;
}
/**
* Test if range is in this range. If the range is equal to this range, will return true.
*/
+1 -1
View File
@@ -2457,7 +2457,7 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
const bracketsContainingActivePosition =
(startLineNumber <= activePosition.lineNumber && activePosition.lineNumber <= endLineNumber)
// Does active position intersect with the view port? -> Intersect bracket pairs with activePosition
? bracketPairs.filter(bp => bp.range.containsPosition(activePosition))
? bracketPairs.filter(bp => Range.strictContainsPosition(bp.range, activePosition))
: this._bracketPairColorizer.getBracketPairsInRange(
Range.fromPositions(activePosition)
);