From 48f1bf1816d01b474f72dbf0aa140edd44acdfd1 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 3 Sep 2019 16:03:03 +0200 Subject: [PATCH] sort positions in Range constructor, so start always comes before end --- src/editor/range.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/editor/range.js b/src/editor/range.js index 1aaf480733..1eebfeeb91 100644 --- a/src/editor/range.js +++ b/src/editor/range.js @@ -15,10 +15,11 @@ limitations under the License. */ export default class Range { - constructor(model, startPosition, endPosition = startPosition) { + constructor(model, positionA, positionB = positionA) { this._model = model; - this._start = startPosition; - this._end = endPosition; + const bIsLarger = positionA.compare(positionB) < 0; + this._start = bIsLarger ? positionA : positionB; + this._end = bIsLarger ? positionB : positionA; } moveStart(delta) {