Ported from bugfix of 2024-06-23.
O7YTBRQYVEM6LR22BJFPAGGF4CQP5R2C4B4KXVOTHUWA32TVZ6BQC
2H76FV5SK3ZWFVQ6ISAOSUJQWW4SSNPRDEI75JIQAJRPIVWPOCDAC
IENTL2ITG2CJE5TRUJGUE65CNC4COAQIQGDMGETZCP5R2VUMS7QQC
NSM73TX3N6HN6CYVX5LHHWQTHOZITHWIWNOWXZQROBGP6KSDEPBAC
AMOPICKVRHMQERJLFPMAAEBV7TL5QACGGSBJWRCMV5R5O3KDVETAC
LXTTOB33N2HCUZFIUDRQGGBVHK2HODRG4NBLH6RXRQZDCHF27BSAC
KKMFQDR43ZWVCDRHQLWWX3FCWCFA3ZSXYOBRJNPHUQZR2XPKWULAC
NVSC4N4KMUHGX5FEOM2DXYA4VHEEQTP3QNY3D7WY4UONVW5LCT2QC
G54H3YG2NEZPW2F6OYT5JPV7KSKVMNW5D3QT3FBCXTJHAQYTV5UAC
2L5MEZV344TOZLVY3432RHJFIRVXFD6O3GWLL5O4CV66BGAFTURQC
LNUHQOGHIOFGJXNGA3DZLYEASLYYDGLN2I3EDZY5ANASQAHCG3YQC
5ZA3BRNYWKSGEBJ4JLA4UBC3LJPT5JBWYCU7PQYRSGX6MJMEWDIQC
ZS5IYZH5EXXPSVIFWS7XW5POEVRRCK6XV6PB36D3EJXJRT22LKOQC
3QNOKBFMKBGXBVJIRHR2444JRRMBTABHE4674NR3DT67RRM2X6GAC
CUFW4EJL75OAA5BS5EXGTM5RMRNJOBBPAXUJADGZ3VLP2ZMKFOTAC
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_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
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)
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)