From 87d38c0a4d3820d894acbc8d3d1dce8d4f1e17f0 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 9 Oct 2017 12:22:17 -0700 Subject: [PATCH] Return a Point from cursor word methods Fixes #15847 --- src/cursor.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cursor.js b/src/cursor.js index 1425f5b49..6cd0cc623 100644 --- a/src/cursor.js +++ b/src/cursor.js @@ -528,7 +528,7 @@ class Cursor extends Model { let result for (let range of ranges) { if (position.isLessThanOrEqual(range.start)) break - if (allowPrevious || position.isLessThanOrEqual(range.end)) result = range.start + if (allowPrevious || position.isLessThanOrEqual(range.end)) result = Point.fromObject(range.start) } return result || (allowPrevious ? new Point(0, 0) : position) @@ -559,7 +559,7 @@ class Cursor extends Model { for (let range of ranges) { if (position.isLessThan(range.start) && !allowNext) break - if (position.isLessThan(range.end)) return range.end + if (position.isLessThan(range.end)) return Point.fromObject(range.end) } return allowNext ? this.editor.getEofBufferPosition() : position @@ -597,9 +597,10 @@ class Cursor extends Model { options.wordRegex || this.wordRegExp(), new Range(new Point(position.row, 0), new Point(position.row, Infinity)) ) - return ranges.find(range => + const range = ranges.find(range => range.end.column >= position.column && range.start.column <= position.column - ) || new Range(position, position) + ) + return range ? Range.fromObject(range) : new Range(position, position) } // Public: Returns the buffer Range for the current line.