Skip to content

Commit 6138cef

Browse files
committed
fix wrong position if selection end is at end of line
1 parent 409f267 commit 6138cef

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/domcoords.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,12 @@ function singleRect(object, bias) {
234234
// : (EditorView, number) → {left: number, top: number, right: number, bottom: number}
235235
// Given a position in the document model, get a bounding box of the
236236
// character at that position, relative to the window.
237-
export function coordsAtPos(view, pos) {
237+
export function coordsAtPos(view, pos, end = false) {
238238
let {node, offset} = view.docView.domFromPos(pos)
239239
let side, rect
240240
if (node.nodeType == 3) {
241241
if (offset < node.nodeValue.length) {
242-
rect = singleRect(textRange(node, offset, offset + 1), -1)
242+
rect = singleRect(textRange(node, offset, (end) ? 0 : offset + 1), -1)
243243
side = "left"
244244
}
245245
if ((!rect || rect.left == rect.right) && offset) {

0 commit comments

Comments
 (0)