bugfix: search upwards
This commit is contained in:
parent
0afd03e721
commit
e85a7e73d0
|
@ -79,7 +79,7 @@ end
|
||||||
|
|
||||||
function Text.search_previous(State)
|
function Text.search_previous(State)
|
||||||
-- search current line
|
-- search current line
|
||||||
local pos = rfind(State.lines[State.cursor1.line].data, State.search_term, State.cursor1.pos)
|
local pos = rfind(State.lines[State.cursor1.line].data, State.search_term, State.cursor1.pos-1)
|
||||||
if pos then
|
if pos then
|
||||||
State.cursor1.pos = pos
|
State.cursor1.pos = pos
|
||||||
end
|
end
|
||||||
|
|
|
@ -2046,6 +2046,25 @@ function test_search()
|
||||||
check_eq(Editor_state.cursor1.pos, 1, 'F - test_search/2/cursor:pos')
|
check_eq(Editor_state.cursor1.pos, 1, 'F - test_search/2/cursor:pos')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function test_search_upwards()
|
||||||
|
io.write('\ntest_search_upwards')
|
||||||
|
App.screen.init{width=120, height=60}
|
||||||
|
Editor_state = edit.initialize_test_state()
|
||||||
|
Editor_state.lines = load_array{'abc abd'}
|
||||||
|
Text.redraw_all(Editor_state)
|
||||||
|
Editor_state.cursor1 = {line=1, pos=2}
|
||||||
|
Editor_state.screen_top1 = {line=1, pos=1}
|
||||||
|
Editor_state.screen_bottom1 = {}
|
||||||
|
edit.draw(Editor_state)
|
||||||
|
-- search for a string
|
||||||
|
edit.run_after_keychord(Editor_state, 'C-f')
|
||||||
|
edit.run_after_textinput(Editor_state, 'a')
|
||||||
|
-- search for previous occurrence
|
||||||
|
edit.run_after_keychord(Editor_state, 'up')
|
||||||
|
check_eq(Editor_state.cursor1.line, 1, 'F - test_search_upwards/2/cursor:line')
|
||||||
|
check_eq(Editor_state.cursor1.pos, 1, 'F - test_search_upwards/2/cursor:pos')
|
||||||
|
end
|
||||||
|
|
||||||
function test_search_wrap()
|
function test_search_wrap()
|
||||||
io.write('\ntest_search_wrap')
|
io.write('\ntest_search_wrap')
|
||||||
App.screen.init{width=120, height=60}
|
App.screen.init{width=120, height=60}
|
||||||
|
|
Loading…
Reference in New Issue