Ported from bugfix of 2024-06-23.
O7YTBRQYVEM6LR22BJFPAGGF4CQP5R2C4B4KXVOTHUWA32TVZ6BQC 2H76FV5SK3ZWFVQ6ISAOSUJQWW4SSNPRDEI75JIQAJRPIVWPOCDAC IENTL2ITG2CJE5TRUJGUE65CNC4COAQIQGDMGETZCP5R2VUMS7QQC NSM73TX3N6HN6CYVX5LHHWQTHOZITHWIWNOWXZQROBGP6KSDEPBAC AMOPICKVRHMQERJLFPMAAEBV7TL5QACGGSBJWRCMV5R5O3KDVETAC LXTTOB33N2HCUZFIUDRQGGBVHK2HODRG4NBLH6RXRQZDCHF27BSAC KKMFQDR43ZWVCDRHQLWWX3FCWCFA3ZSXYOBRJNPHUQZR2XPKWULAC NVSC4N4KMUHGX5FEOM2DXYA4VHEEQTP3QNY3D7WY4UONVW5LCT2QC G54H3YG2NEZPW2F6OYT5JPV7KSKVMNW5D3QT3FBCXTJHAQYTV5UAC 2L5MEZV344TOZLVY3432RHJFIRVXFD6O3GWLL5O4CV66BGAFTURQC LNUHQOGHIOFGJXNGA3DZLYEASLYYDGLN2I3EDZY5ANASQAHCG3YQC 5ZA3BRNYWKSGEBJ4JLA4UBC3LJPT5JBWYCU7PQYRSGX6MJMEWDIQC ZS5IYZH5EXXPSVIFWS7XW5POEVRRCK6XV6PB36D3EJXJRT22LKOQC 3QNOKBFMKBGXBVJIRHR2444JRRMBTABHE4674NR3DT67RRM2X6GAC CUFW4EJL75OAA5BS5EXGTM5RMRNJOBBPAXUJADGZ3VLP2ZMKFOTAC endfunction 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 stringedit.run_after_keychord(Editor_state, 'C-f', 'f')edit.run_after_keychord(Editor_state, 'down', 'down')-- no crash
endfunction 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 stringedit.run_after_keychord(Editor_state, 'C-f', 'f')edit.run_after_keychord(Editor_state, 'down', 'down')-- no crash
if State.lines[State.cursor1.line].mode == 'text' then
endendfunction edit.put_cursor_on_next_text_line_wrapping_around_if_necessary(State)local line = State.cursor1.linelocal max = #State.linesfor _ = 1, max-1 doline = (line+1) % maxif State.lines[line].mode == 'text' thenState.cursor1.line = lineState.cursor1.pos = 1
State.cursor1.line = State.cursor1.line+1State.cursor1.pos = 1
endendfunction edit.put_cursor_on_next_text_loc_wrapping_around_if_necessary(State)local cursor_line = State.lines[State.cursor1.line].dataif State.cursor1.pos <= utf8.len(cursor_line) thenState.cursor1.pos = State.cursor1.pos + 1elseedit.put_cursor_on_next_text_line_wrapping_around_if_necessary(State)
if State.lines[State.cursor1.line].mode == 'text' then
endendfunction edit.put_cursor_on_next_text_line_wrapping_around_if_necessary(State)local line = State.cursor1.linelocal max = #State.linesfor _ = 1, max-1 doline = (line+1) % maxif State.lines[line].mode == 'text' thenState.cursor1.line = lineState.cursor1.pos = 1
State.cursor1.line = State.cursor1.line+1State.cursor1.pos = 1
endendfunction edit.put_cursor_on_next_text_loc_wrapping_around_if_necessary(State)local cursor_line = State.lines[State.cursor1.line].dataif State.cursor1.pos <= utf8.len(cursor_line) thenState.cursor1.pos = State.cursor1.pos + 1elseedit.put_cursor_on_next_text_line_wrapping_around_if_necessary(State)