bugfix: check after cursor on same line when searching upwards

[?]
Aug 12, 2022, 5:23 AM
AMOPICKVRHMQERJLFPMAAEBV7TL5QACGGSBJWRCMV5R5O3KDVETAC

Dependencies

  • [2] LLAOOMUL bugfix: search upwards
  • [3] LXTTOB33 extract a couple of files
  • [4] LF7BWEG4 group all editor globals
  • [5] 5ZA3BRNY add state arg to a few functions
  • [*] MSOQI3A5 bugfix: check before cursor on same line

Change contents

  • edit in text_tests.lua at line 2086
    [7.716]
    function test_search_wrap_upwards()
    io.write('\ntest_search_wrap_upwards')
    App.screen.init{width=120, height=60}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc abd'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=1, pos=1}
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.screen_bottom1 = {}
    edit.draw(Editor_state)
    -- search upwards for a string
    edit.run_after_keychord(Editor_state, 'C-f')
    edit.run_after_textinput(Editor_state, 'a')
    edit.run_after_keychord(Editor_state, 'up')
    -- cursor wraps
    check_eq(Editor_state.cursor1.line, 1, 'F - test_search_wrap_upwards/1/cursor:line')
    check_eq(Editor_state.cursor1.pos, 5, 'F - test_search_wrap_upwards/1/cursor:pos')
    end
  • replacement in search.lua at line 71
    [3.1072][3.50759:50784](),[3.50759][3.50759:50784]()
    -- search current line
    [3.1072]
    [2.751]
    -- search current line before cursor
  • edit in search.lua at line 77
    [3.50919]
    [3.1199]
    -- search lines above cursor
  • edit in search.lua at line 96
    [3.51322]
    [3.51322]
    end
    end
    if pos == nil then
    -- search current line after cursor
    pos = rfind(State.lines[State.cursor1.line].data, State.search_term)
    if pos and pos > State.cursor1.pos then
    State.cursor1.pos = pos