QSHQIVF3JASUFN56WXNZRZW2CQAZXB2V43YQJVBZ3FPRTVULZJ6QC
CZ6X73VY6CKBHNLFLWA4DXLYVIWI5W4WPDIHJL3N6OBMTXQDC3RQC
S7CSVBHZ4AORIP4VIQETFAVXVMNKERVOI5DENNTU73ZO2L667N7QC
R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC
JOPVPUSAMMU6RFVDQR4NJC4GNNUFB7GPKVH7OS5FKCYS5QZ53VLQC
4Y2QDDAZT2X7SEWYNFEMTYJC6O3UBK4ID3AIOAZZNE2S2H57UQSAC
RAXUQQ6ZTTH4WCEDDLVXJSZ4E2W6NBEGTANCBDK57YO6ASCEI2CQC
34BZ5ZKNAB4XQGXOPVBZHBDYD5D3X4V6T72XZSR5LJXF4UIVSWQAC
I4S4EFYX6P4RSBCCRAYYXA5MD63T3YINN36LOQXXDKMN7MVS6WNAC
3PSFWAILGRA4OYXWS2DX7VF332AIBPYBXHEA4GIQY2XEJVD65UMAC
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
end
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)
elseif chord == 'down' then
if #State.search_term > 0 then
edit.put_cursor_on_next_text_loc_wrapping_around_if_necessary(State)
Text.search_next(State)
end
elseif chord == 'up' then
Text.search_previous(State)
end
return
elseif chord == 'C-f' then
State.search_term = ''
State.search_backup = {
Text.search_next(State)
end
end
break
end
break
end