- # now we're above
- if new_loc.x <= old_loc.x
- @move_cursor new_cursor
- return false
- target_y = new_loc.y
- # search leftward, until we find the closest position
- while new_loc.x > old_loc.x and new_loc.y is target_y
- prev_loc = new_loc
- prev_cursor = new_cursor
- new_cursor = find_prev_cursor_position @tree, new_cursor[0], new_cursor[1]
- break unless new_cursor?
- new_loc = cursor_to_xyh new_cursor[0], new_cursor[1]
- # move cursor to prev_cursor or new_cursor
- if new_cursor?
- if new_loc.y is target_y
- # both valid, and on the same line, use closest
- if (old_loc.x - new_loc.x) < (prev_loc.x - old_loc.x)
- @move_cursor new_cursor
- else
- @move_cursor prev_cursor
+ if new_cursor.y is target_y
+ # both valid, and on the same line, use closest
+ if (@cursor.x - new_cursor.x) < (prev_cursor.x - @cursor.x)
+ @move_cursor new_cursor