From e3b396215f59cd45b7d7c510dcddea8354f756aa Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Wed, 25 May 2016 09:12:52 -0400 Subject: [PATCH] replace del key hack with one that uses backspace code --- editor.coffee | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/editor.coffee b/editor.coffee index 36c6660..238625c 100644 --- a/editor.coffee +++ b/editor.coffee @@ -952,15 +952,22 @@ class PeachHTML5Editor return false when KEY_DELETE return false unless @cursor? - return false unless @cursor.i < @cursor.n.text.length - @remove_character @cursor.n, @cursor.i - @text_cleanup @cursor.n - @changed() - new_cursor = new_cursor_position n: @cursor.n, i: @cursor.i + new_cursor = find_next_cursor_position @tree, n: @cursor.n, i: @cursor.i + # try moving cursor right and then running backspace code + # TODO replace this hack with a real implementation if new_cursor? - @move_cursor new_cursor - else - @kill_cursor() + # try to detect common case where cursor goes inside an block, + # but doesn't pass a character (and advance one more in that case) + if new_cursor.n isnt @cursor.n and new_cursor.i is 0 + if new_cursor.n.type is 'text' and new_cursor.n.text.length > 0 + if new_cursor.n.parent? + unless @is_display_block new_cursor.n.parent + # FIXME should test run sibling + new_cursor = new_cursor_position n: new_cursor.n, i: new_cursor.i + 1 + if new_cursor? + if new_cursor.n isnt @cursor.n or new_cursor.i isnt @cursor.i + @move_cursor new_cursor + @on_key_backspace e return false when KEY_ENTER @on_key_enter e @@ -1159,7 +1166,7 @@ class PeachHTML5Editor @_merge_left merge_state @text_cleanup merge_state.n new_cursor = new_cursor_position n: merge_state.n, i: merge_state.i - # FIXME CONTINUE + # FIXME implement this: # else # if prev (in run) is inline-block # if that inline-block has text in it # delete last char in prev inlineblock -- 1.7.10.4