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O4CV66BGAFTURQC
6PRGXS6XLC7P2EASPUU64OHJUIMEDWAWRLFB265KSFPJIMTKQ6WAC
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
end
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
end
function 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.line
while line < #State.lines do
line = line+1
if State.lines[line].mode == 'text' then
State.cursor1.line = line
State.cursor1.pos = 1
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
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)
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 then
edit.put_cursor_on_next_text_loc_wrapping_around_if_necessary(State)
Text.search_next(State)
end
Text.search_previous(State)
end
return
elseif chord == 'C-f' then
State.search_term = ''
State.search_backup = {
elseif chord == 'up' then
elseif chord == 'down' then
end
break
end
break
end
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
end
function 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 string
edit.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
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
State.cursor1.line = State.cursor1.line+1
State.cursor1.pos = 1
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)
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
break
end
end
end
function edit.put_cursor_on_next_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)
end
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)
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
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
if #State.search_term > 0 then
edit.put_cursor_on_next_text_loc_wrapping_around_if_necessary(State)
Text.search_next(State)
end
Text.search_previous(State)