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C 6PRGXS6XLC7P2EASPUU64OHJUIMEDWAWRLFB265KSFPJIMTKQ6WAC 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 crashendEditor_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 crashendfunction test_search_downwards_from_final_pos_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=3}
local line = State.cursor1.linewhile line < #State.lines doline = line+1if State.lines[line].mode == 'text' thenState.cursor1.line = lineState.cursor1.pos = 1endendfunction 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 = 1endendfunction 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)State.cursor = deepcopy(State.search_backup.cursor)State.screen_top = deepcopy(State.search_backup.screen_top)Text.search_next(State)if #State.search_term > 0 thenedit.put_cursor_on_next_text_loc_wrapping_around_if_necessary(State)Text.search_next(State)endText.search_previous(State)endreturnelseif chord == 'C-f' thenState.search_term = ''State.search_backup = {elseif chord == 'up' thenelseif chord == 'down' thenendbreakendbreakend
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 crashendfunction test_search_downwards_from_final_pos_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=3}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)
endfunction 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 = 1breakendendendfunction edit.put_cursor_on_next_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)end
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)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 = 1local line = State.cursor1.linewhile line < #State.lines doline = line+1if State.lines[line].mode == 'text' thenState.cursor1.line = lineState.cursor1.pos = 1if #State.search_term > 0 thenedit.put_cursor_on_next_text_loc_wrapping_around_if_necessary(State)Text.search_next(State)endText.search_previous(State)