bugfix: restart search on backspace

akkartik
Oct 29, 2024, 4:50 AM
O7YTBRQYVEM6LR22BJFPAGGF4CQP5R2C4B4KXVOTHUWA32TVZ6BQC

Dependencies

  • [2] 2H76FV5S bugfix: searching files containing unicode
  • [3] IENTL2IT indent
  • [4] NSM73TX3 crap, fix some final changes in the source editor
  • [5] CUFW4EJL reorganize app.lua and its comments
  • [6] 2L5MEZV3 experiment: new edit namespace
  • [7] 2TCIWW6Z stop caching starty
  • [8] KKMFQDR4 editing source code from within the app
  • [9] LF7BWEG4 group all editor globals
  • [10] IX5YTLSV state validation in source editor as well
  • [11] 5ZA3BRNY add state arg to a few functions
  • [12] 7VGDIPLC more robust state validation
  • [13] ZS5IYZH5 stop caching screen_bottom1
  • [14] G54H3YG2 get rid of all bifold text
  • [15] NVSC4N4K change a helper slightly
  • [16] T6A5SZGB bugfix: restart search on backspace
  • [17] LNUHQOGH start passing in Editor_state explicitly
  • [*] LXTTOB33 extract a couple of files
  • [*] AMOPICKV bugfix: check after cursor on same line when searching upwards
  • [*] 3QNOKBFM beginnings of a test harness

Change contents

  • edit in text_tests.lua at line 2075
    [2.680]
    [20.752]
    end
    function test_search_downwards_from_end_of_line()
    App.screen.init{width=120, height=60}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc', 'def', 'ghi'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=1, pos=4}
    Editor_state.screen_top1 = {line=1, pos=1}
    edit.draw(Editor_state)
    -- search for empty string
    edit.run_after_keychord(Editor_state, 'C-f', 'f')
    edit.run_after_keychord(Editor_state, 'down', 'down')
    -- no crash
  • edit in source_text_tests.lua at line 2075
    [2.1363]
    [5.83671]
    end
    function test_search_downwards_from_end_of_line()
    App.screen.init{width=120, height=60}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc', 'def', 'ghi'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=1, pos=4}
    Editor_state.screen_top1 = {line=1, pos=1}
    edit.draw(Editor_state)
    -- search for empty string
    edit.run_after_keychord(Editor_state, 'C-f', 'f')
    edit.run_after_keychord(Editor_state, 'down', 'down')
    -- no crash
  • replacement in source_edit.lua at line 145
    [5.108][5.108:124](),[5.124][3.12:59]()
    while true do
    if State.cursor1.line >= #State.lines then
    [5.108]
    [3.59]
    local line = State.cursor1.line
    while line < #State.lines do
    line = line+1
    if State.lines[line].mode == 'text' then
    State.cursor1.line = line
    State.cursor1.pos = 1
  • replacement in source_edit.lua at line 153
    [3.79][3.79:138]()
    if State.lines[State.cursor1.line].mode == 'text' then
    [3.79]
    [3.138]
    end
    end
    function edit.put_cursor_on_next_text_line_wrapping_around_if_necessary(State)
    local line = State.cursor1.line
    local max = #State.lines
    for _ = 1, max-1 do
    line = (line+1) % max
    if State.lines[line].mode == 'text' then
    State.cursor1.line = line
    State.cursor1.pos = 1
  • replacement in source_edit.lua at line 166
    [3.158][3.158:230]()
    State.cursor1.line = State.cursor1.line+1
    State.cursor1.pos = 1
    [3.158]
    [5.321]
    end
    end
    function edit.put_cursor_on_next_text_loc_wrapping_around_if_necessary(State)
    local cursor_line = State.lines[State.cursor1.line].data
    if State.cursor1.pos <= utf8.len(cursor_line) then
    State.cursor1.pos = State.cursor1.pos + 1
    else
    edit.put_cursor_on_next_text_line_wrapping_around_if_necessary(State)
  • edit in source_edit.lua at line 431
    [5.158844]
    [5.158874]
    State.cursor = deepcopy(State.search_backup.cursor)
    State.screen_top = deepcopy(State.search_backup.screen_top)
    Text.search_next(State)
  • replacement in source_edit.lua at line 435
    [5.158906][5.7223:7269]()
    State.cursor1.pos = State.cursor1.pos+1
    [5.158906]
    [5.159057]
    edit.put_cursor_on_next_text_loc_wrapping_around_if_necessary(State)
  • replacement in edit.lua at line 143
    [5.441][5.441:457](),[5.457][3.248:295]()
    while true do
    if State.cursor1.line >= #State.lines then
    [5.441]
    [3.295]
    local line = State.cursor1.line
    while line < #State.lines do
    line = line+1
    if State.lines[line].mode == 'text' then
    State.cursor1.line = line
    State.cursor1.pos = 1
  • replacement in edit.lua at line 151
    [3.315][3.315:374]()
    if State.lines[State.cursor1.line].mode == 'text' then
    [3.315]
    [3.374]
    end
    end
    function edit.put_cursor_on_next_text_line_wrapping_around_if_necessary(State)
    local line = State.cursor1.line
    local max = #State.lines
    for _ = 1, max-1 do
    line = (line+1) % max
    if State.lines[line].mode == 'text' then
    State.cursor1.line = line
    State.cursor1.pos = 1
  • replacement in edit.lua at line 164
    [3.394][3.394:466]()
    State.cursor1.line = State.cursor1.line+1
    State.cursor1.pos = 1
    [3.394]
    [5.654]
    end
    end
    function edit.put_cursor_on_next_text_loc_wrapping_around_if_necessary(State)
    local cursor_line = State.lines[State.cursor1.line].data
    if State.cursor1.pos <= utf8.len(cursor_line) then
    State.cursor1.pos = State.cursor1.pos + 1
    else
    edit.put_cursor_on_next_text_line_wrapping_around_if_necessary(State)
  • replacement in edit.lua at line 429
    [5.11621][5.7491:7537]()
    State.cursor1.pos = State.cursor1.pos+1
    [5.11621]
    [5.2118]
    edit.put_cursor_on_next_text_loc_wrapping_around_if_necessary(State)
  • replacement in app.lua at line 134
    [5.8755][4.310:345]()
    --? test_click_below_all_lines()
    [5.8755]
    [5.842]
    --? test_search()