bugfix: skip over drawings when searching
This commit is contained in:
parent
6f74f95a46
commit
3265abacb4
|
@ -22,13 +22,19 @@ function Text.draw_search_bar(State)
|
|||
end
|
||||
|
||||
function Text.search_next(State)
|
||||
local pos
|
||||
-- search current line
|
||||
local pos = State.lines[State.cursor1.line].data:find(State.search_term, State.cursor1.pos)
|
||||
local line = State.lines[State.cursor1.line]
|
||||
if line.mode == 'text' then
|
||||
pos = line.data:find(State.search_term, State.cursor1.pos)
|
||||
if pos then
|
||||
State.cursor1.pos = pos
|
||||
end
|
||||
end
|
||||
if pos == nil then
|
||||
for i=State.cursor1.line+1,#State.lines do
|
||||
local line = State.lines[i]
|
||||
if line.mode == 'text' then
|
||||
pos = State.lines[i].data:find(State.search_term)
|
||||
if pos then
|
||||
State.cursor1.line = i
|
||||
|
@ -37,6 +43,7 @@ function Text.search_next(State)
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if pos == nil then
|
||||
-- wrap around
|
||||
for i=1,State.cursor1.line-1 do
|
||||
|
|
|
@ -1970,18 +1970,12 @@ function test_search()
|
|||
io.write('\ntest_search')
|
||||
App.screen.init{width=120, height=60}
|
||||
Editor_state = edit.initialize_test_state()
|
||||
Editor_state.lines = load_array{'abc', 'def', 'ghi', 'deg'}
|
||||
Editor_state.lines = load_array{'```lines', '```', 'def', 'ghi', 'deg'}
|
||||
Text.redraw_all(Editor_state)
|
||||
Editor_state.cursor1 = {line=1, pos=1}
|
||||
Editor_state.screen_top1 = {line=1, pos=1}
|
||||
Editor_state.screen_bottom1 = {}
|
||||
edit.draw(Editor_state)
|
||||
local y = Editor_state.top
|
||||
App.screen.check(y, 'abc', 'F - test_search/baseline/screen:1')
|
||||
y = y + Editor_state.line_height
|
||||
App.screen.check(y, 'def', 'F - test_search/baseline/screen:2')
|
||||
y = y + Editor_state.line_height
|
||||
App.screen.check(y, 'ghi', 'F - test_search/baseline/screen:3')
|
||||
-- search for a string
|
||||
edit.run_after_keychord(Editor_state, 'C-f')
|
||||
edit.run_after_textinput(Editor_state, 'd')
|
||||
|
@ -1990,6 +1984,7 @@ function test_search()
|
|||
check_eq(Editor_state.cursor1.pos, 1, 'F - test_search/1/cursor:pos')
|
||||
-- reset cursor
|
||||
Editor_state.cursor1 = {line=1, pos=1}
|
||||
Editor_state.screen_top1 = {line=1, pos=1}
|
||||
-- search for second occurrence
|
||||
edit.run_after_keychord(Editor_state, 'C-f')
|
||||
edit.run_after_textinput(Editor_state, 'de')
|
||||
|
|
Loading…
Reference in New Issue