~akkartik/text2.love

910fb0c8fa5855a74634846dd6470c2f4f6da54e — Kartik K. Agaram a month ago 373c3c4 main
bugfix in search UI

Scenario:
  position cursor before final character of a line
  press C-f
  press down arrow

Before this commit the app would crash.
1 files changed, 6 insertions(+), 2 deletions(-)

M edit.lua
M edit.lua => edit.lua +6 -2
@@ 405,8 405,10 @@ function I.on_keychord_pressed(editor, chord, key)
      editor.screen_top = I.deepcopy(editor.search_backup.screen_top)
      I.search_next(editor)
    elseif chord == 'down' then
      I.on_right_arrow(editor)
      I.search_next(editor)
      if #editor.search_term > 0 then
        I.on_right_arrow(editor)
        I.search_next(editor)
      end
    elseif chord == 'up' then
      I.search_previous(editor)
    end


@@ 1478,6 1480,7 @@ function I.draw_search_bar(editor)
end

function I.search_next(editor)
  if #editor.search_term == 0 then return end
  local offset
  -- search current line from cursor
  local curr_pos = editor.cursor.pos


@@ 1528,6 1531,7 @@ function I.search_next(editor)
end

function I.search_previous(editor)
  if #editor.search_term == 0 then return end
  local offset
  -- search current line before cursor
  local curr_pos = editor.cursor.pos