Skip to content

Commit

Permalink
fix wrong position if selection end is at end of line
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrissi2812 committed Mar 6, 2019
1 parent 409f267 commit 6138cef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/domcoords.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6138cef

Please sign in to comment.