X-Git-Url: https://jasonwoof.com/gitweb/?p=peach-html5-editor.git;a=blobdiff_plain;f=editor.coffee;h=d3b428a951bd0a82cf02ec2ce14140aff6fc9ea4;hp=a9d0a3c95d352931672379cbb953bc8fd6b155de;hb=7c692d45783faabd8cac58eef62e5de41ddeb5c8;hpb=b3b872ef2a2200cd1e674845f0215341c1e67bfd diff --git a/editor.coffee b/editor.coffee index a9d0a3c..d3b428a 100644 --- a/editor.coffee +++ b/editor.coffee @@ -388,13 +388,15 @@ find_prev_cursor_position = (tree, n, i) -> if prev_xyh.x < orig_xyh.x or prev_xyh.y < orig_xyh.y return [n, prev_i] return [n, i - 1] - found_prev = n? + found_prev = null found = null traverse_tree tree, (node) -> if node.type is 'text' + unless n? + found = node + return true if node is n - if found_prev? - found = found_prev + found = found_prev # null if n is the first text node return true found_prev = node return false