From 7a04a3723bb7162ad221d3f3334fe7fcfaf28908 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Sat, 31 Jan 2026 18:23:29 +0100 Subject: [PATCH] use selection begin as pos in backwards search --- application/note.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/application/note.c b/application/note.c index 3781a45..b64fe85 100644 --- a/application/note.c +++ b/application/note.c @@ -382,12 +382,12 @@ int text_search( return 0; } -static int get_search_start_pos(NoteModel *note) { +static int get_search_start_pos(NoteModel *note, bool backwards) { int pos = note->text->position(note->text); int sel_begin, sel_end; note->text->selection(note->text, &sel_begin, &sel_end); - if(sel_end >= 0) { - pos = sel_end; + if(sel_begin >= 0 && sel_end >= 0) { + pos = backwards ? sel_begin : sel_end; } return pos; } @@ -399,7 +399,7 @@ static void note_search(NoteModel *note, bool backwards) { } cxstring text = cx_str(ui_get(note->text)); - int pos = get_search_start_pos(note); + int pos = get_search_start_pos(note, backwards); bool cs = (bool)ui_get(note->search_cs); bool regex = (bool)ui_get(note->search_regex); -- 2.47.3