]> uap-core.de Git - note.git/commitdiff
use selection begin as pos in backwards search
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Sat, 31 Jan 2026 17:23:29 +0000 (18:23 +0100)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Sat, 31 Jan 2026 17:23:29 +0000 (18:23 +0100)
application/note.c

index 3781a45c365082e0949c19260e82181123149bf3..b64fe855abb28bd1b83af88cc731e6388d4efa14 100644 (file)
@@ -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);