diff options
Diffstat (limited to 'search.lua')
-rw-r--r-- | search.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/search.lua b/search.lua index 4ebd8ab..1872b9e 100644 --- a/search.lua +++ b/search.lua @@ -68,12 +68,13 @@ function Text.search_next(State) end function Text.search_previous(State) - -- search current line + -- search current line before cursor local pos = rfind(State.lines[State.cursor1.line].data, State.search_term, State.cursor1.pos-1) if pos then State.cursor1.pos = pos end if pos == nil then + -- search lines above cursor for i=State.cursor1.line-1,1,-1 do pos = rfind(State.lines[i].data, State.search_term) if pos then @@ -95,6 +96,13 @@ function Text.search_previous(State) end end if pos == nil then + -- search current line after cursor + pos = rfind(State.lines[State.cursor1.line].data, State.search_term) + if pos and pos > State.cursor1.pos then + State.cursor1.pos = pos + end + end + if pos == nil then State.cursor1.line = State.search_backup.cursor.line State.cursor1.pos = State.search_backup.cursor.pos State.screen_top1.line = State.search_backup.screen_top.line |