[gnote] Fix find previous match



commit 7a63b8f8b03da4329134b16c5f8b28bb2483651a
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Nov 29 20:52:18 2020 +0200

    Fix find previous match

 src/notewindow.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/notewindow.cpp b/src/notewindow.cpp
index 6c3db72f..327c3690 100644
--- a/src/notewindow.cpp
+++ b/src/notewindow.cpp
@@ -631,6 +631,7 @@ namespace gnote {
     if (m_current_matches.empty() || m_current_matches.size() == 0)
       return false;
 
+    Match *previous_match = nullptr;
     for (auto & match : m_current_matches) {
       Glib::RefPtr<NoteBuffer> buffer = match.buffer;
       Gtk::TextIter selection_start, selection_end;
@@ -638,9 +639,15 @@ namespace gnote {
       Gtk::TextIter end = buffer->get_iter_at_mark(match.start_mark);
 
       if (end.get_offset() < selection_start.get_offset()) {
-        jump_to_match(match);
-        return true;
+        previous_match = &match;
       }
+      else {
+        break;
+      }
+    }
+    if(previous_match) {
+      jump_to_match(*previous_match);
+      return true;
     }
 
     return false;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]