From 6138cef86c3b7fe511cb30b563a2e0df13698147 Mon Sep 17 00:00:00 2001 From: Chrissi2812 Date: Wed, 6 Mar 2019 13:42:31 +0100 Subject: [PATCH] fix wrong position if selection end is at end of line --- src/domcoords.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/domcoords.js b/src/domcoords.js index a57d39ae..09da1356 100644 --- a/src/domcoords.js +++ b/src/domcoords.js @@ -234,12 +234,12 @@ function singleRect(object, bias) { // : (EditorView, number) → {left: number, top: number, right: number, bottom: number} // Given a position in the document model, get a bounding box of the // character at that position, relative to the window. -export function coordsAtPos(view, pos) { +export function coordsAtPos(view, pos, end = false) { let {node, offset} = view.docView.domFromPos(pos) let side, rect if (node.nodeType == 3) { if (offset < node.nodeValue.length) { - rect = singleRect(textRange(node, offset, offset + 1), -1) + rect = singleRect(textRange(node, offset, (end) ? 0 : offset + 1), -1) side = "left" } if ((!rect || rect.left == rect.right) && offset) {