bugfix: check before cursor on same line

[?]
Aug 12, 2022, 3:09 AM
MSOQI3A5BC5PY2MZXZQAQ4EQDT4KICQJPN3YUZVDYTWXSPZWBLIAC

Dependencies

  • [2] EETIR4GX bugfix: skip over drawings when searching
  • [3] LF7BWEG4 group all editor globals
  • [4] LXTTOB33 extract a couple of files
  • [5] 5ZA3BRNY add state arg to a few functions
  • [*] FZBXBUFF bugfix: search

Change contents

  • edit in text_tests.lua at line 2048
    [7.1427]
    function test_search_wrap()
    io.write('\ntest_search_wrap')
    App.screen.init{width=120, height=60}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=1, pos=3}
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.screen_bottom1 = {}
    edit.draw(Editor_state)
    -- search for a string
    edit.run_after_keychord(Editor_state, 'C-f')
    edit.run_after_textinput(Editor_state, 'a')
    edit.run_after_keychord(Editor_state, 'return')
    -- cursor wraps
    check_eq(Editor_state.cursor1.line, 1, 'F - test_search_wrap/1/cursor:line')
    check_eq(Editor_state.cursor1.pos, 1, 'F - test_search_wrap/1/cursor:pos')
    end
  • replacement in search.lua at line 24
    [3.39][3.49731:49756](),[2.139][3.49731:49756](),[3.49731][3.49731:49756]()
    -- search current line
    [2.139]
    [2.140]
    -- search current line from cursor
  • edit in search.lua at line 33
    [3.49889]
    [3.164]
    -- search lines below cursor
  • edit in search.lua at line 58
    [3.50317]
    [3.489]
    -- search current line until cursor
    local line = State.lines[State.cursor1.line]
    if line.mode == 'text' then
    pos = line.data:find(State.search_term)
    if pos and pos < State.cursor1.pos then
    State.cursor1.pos = pos
    end
    end
    end
    if pos == nil then