diff --git a/src/vs/editor/common/core/range.ts b/src/vs/editor/common/core/range.ts index e9f53ab665b..f58491416bd 100644 --- a/src/vs/editor/common/core/range.ts +++ b/src/vs/editor/common/core/range.ts @@ -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. */ diff --git a/src/vs/editor/common/model/textModel.ts b/src/vs/editor/common/model/textModel.ts index c1763b1af7a..a55573196e5 100644 --- a/src/vs/editor/common/model/textModel.ts +++ b/src/vs/editor/common/model/textModel.ts @@ -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) );