From 0afd03e72128f691d702ec67f317e6fbf407724e Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 11 Aug 2022 20:09:59 -0700 Subject: bugfix: check before cursor on same line --- search.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'search.lua') diff --git a/search.lua b/search.lua index b578668..95a7f32 100644 --- a/search.lua +++ b/search.lua @@ -21,7 +21,7 @@ end function Text.search_next(State) local pos - -- search current line + -- search current line from cursor local line = State.lines[State.cursor1.line] if line.mode == 'text' then pos = line.data:find(State.search_term, State.cursor1.pos) @@ -30,6 +30,7 @@ function Text.search_next(State) end end if pos == nil then + -- search lines below cursor for i=State.cursor1.line+1,#State.lines do local line = State.lines[i] if line.mode == 'text' then @@ -53,6 +54,16 @@ function Text.search_next(State) end end end + if pos == nil then + -- search current line until cursor + local line = State.lines[State.cursor1.line] + if line.mode == 'text' then + pos = line.data:find(State.search_term) + if pos and pos < State.cursor1.pos then + State.cursor1.pos = pos + end + end + end if pos == nil then State.cursor1.line = State.search_backup.cursor.line State.cursor1.pos = State.search_backup.cursor.pos -- cgit 1.4.1-2-gfad0