[tomboy] NoteWindow.cs: fix note search to work with multibyte characters
- From: Alex Tereschenko <alexter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tomboy] NoteWindow.cs: fix note search to work with multibyte characters
- Date: Sat, 27 May 2017 18:22:21 +0000 (UTC)
commit 3540348a968b27831e44300cb94370663f29033a
Author: Alex Tereschenko <frozen and blue gmail com>
Date: Tue May 16 23:26:16 2017 +0200
NoteWindow.cs: fix note search to work with multibyte characters
Closes #45.
Signed-off-by: Alex Tereschenko <frozen and blue gmail com>
Tomboy/NoteWindow.cs | 20 ++++++++------------
Tomboy/Notebooks/NotebookManager.cs | 1 +
2 files changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/Tomboy/NoteWindow.cs b/Tomboy/NoteWindow.cs
index 410e28e..f224d36 100644
--- a/Tomboy/NoteWindow.cs
+++ b/Tomboy/NoteWindow.cs
@@ -1233,37 +1233,33 @@ namespace Tomboy
note_text = note_text.ToLower ();
foreach (string word in words) {
- int idx = 0;
bool this_word_found = false;
if (word == String.Empty)
continue;
+ Gtk.TextIter searchiter = buffer.GetIterAtOffset (0);
while (true) {
- idx = note_text.IndexOf (word, idx);
+ Gtk.TextIter startiter, enditer;
+ bool word_found = searchiter.ForwardSearch (word,
TextSearchFlags.VisibleOnly, out startiter, out enditer, buffer.EndIter);
- if (idx == -1) {
+ if (!word_found) {
if (this_word_found)
break;
else
return null;
}
- this_word_found = true;
-
- Gtk.TextIter start = buffer.GetIterAtOffset (idx);
- Gtk.TextIter end = start;
- end.ForwardChars (word.Length);
+ searchiter = enditer;
+ this_word_found = word_found;
Match match = new Match ();
match.Buffer = buffer;
- match.StartMark = buffer.CreateMark (null, start, false);
- match.EndMark = buffer.CreateMark (null, end, true);
+ match.StartMark = buffer.CreateMark (null, startiter, false);
+ match.EndMark = buffer.CreateMark (null, enditer, true);
match.Highlighting = false;
matches.Add (match);
-
- idx += word.Length;
}
}
diff --git a/Tomboy/Notebooks/NotebookManager.cs b/Tomboy/Notebooks/NotebookManager.cs
index 2a7d4da..21c9658 100644
--- a/Tomboy/Notebooks/NotebookManager.cs
+++ b/Tomboy/Notebooks/NotebookManager.cs
@@ -372,6 +372,7 @@ namespace Tomboy.Notebooks
dialog.DefaultResponse = Gtk.ResponseType.No;
int response = dialog.Run ();
dialog.Destroy ();
+ Logger.Debug("Return was {0}", response);
if (response != (int) Gtk.ResponseType.Yes)
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]