- # delete text node
- @remove_node @cursor.n
- # delete any inline parents
- n = @cursor.n.parent
- while n? and n isnt block
- # FIXME break if anything else in the text run is in here too
- while n.children.length > 0
- @move_node n.children[0], n.parent, n
- @remove_node n
- n = n.parent
- # update cursor dest in case things moved around
+ # delete text node and cleanup emptied parents
+ run_i = run.indexOf @cursor.n
+ @_backspace_node_helper @cursor.n, run, run_i
+ # see if new adjacent siblings should merge
+ # TODO make smarter
+ if run_i > 0 and run_i + 1 < run.length
+ if run[run_i - 1].type is 'text' and run[run_i + 1].type is 'text'
+ merge_state = n: run[run_i + 1]
+ @_merge_left merge_state
+ if merge_state.moved_cursor
+ new_cursor = merge_state
+ # update whitespace preservation
+ @text_cleanup(block)
+ # update cursor x/y in case things moved around