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;
}
}
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);