From: Olaf Wintermann Date: Sat, 31 Jan 2026 17:23:29 +0000 (+0100) Subject: use selection begin as pos in backwards search X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=7a04a3723bb7162ad221d3f3334fe7fcfaf28908;p=note.git use selection begin as pos in backwards search --- 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);