[tomboy] Added "search for phrases". Fixes bug #551097.
- From: Sanford Armstrong <sharm src gnome org>
- To: svn-commits-list gnome org
- Subject: [tomboy] Added "search for phrases". Fixes bug #551097.
- Date: Sun, 24 May 2009 09:35:29 -0400 (EDT)
commit ee0d79181f198d732168b3888eedd394c0e19a60
Author: Jan Rüegg <rggjan gmail com>
Date: Fri May 22 15:21:07 2009 +0200
Added "search for phrases". Fixes bug #551097.
---
Tomboy/NoteWindow.cs | 2 +-
Tomboy/Search.cs | 24 +++++++++++++++++++++---
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/Tomboy/NoteWindow.cs b/Tomboy/NoteWindow.cs
index 87e2fed..80abfcc 100644
--- a/Tomboy/NoteWindow.cs
+++ b/Tomboy/NoteWindow.cs
@@ -931,7 +931,7 @@ namespace Tomboy
text = text.ToLower ();
- string [] words = text.Split (' ', '\t', '\n');
+ string [] words = Search.SplitWatchingQuotes (text);
current_matches =
FindMatchesInBuffer (note.Buffer, words);
diff --git a/Tomboy/Search.cs b/Tomboy/Search.cs
index 81b106b..bc0c7ff 100644
--- a/Tomboy/Search.cs
+++ b/Tomboy/Search.cs
@@ -36,10 +36,10 @@ namespace Tomboy
bool case_sensitive,
Notebooks.Notebook selected_notebook)
{
- string [] words = query.Split (' ', '\t', '\n');
+ string [] words = Search.SplitWatchingQuotes (query);
// Used for matching in the raw note XML
- string [] encoded_words = XmlEncoder.Encode (query).Split (' ', '\t', '\n');
+ string [] encoded_words = SplitWatchingQuotes (XmlEncoder.Encode (query));
Dictionary<Note,int> temp_matches = new Dictionary<Note,int>();
// Skip over notes that are template notes
@@ -73,8 +73,26 @@ namespace Tomboy
}
return temp_matches;
}
+
+ static public string [] SplitWatchingQuotes (string text)
+ {
+ string [] phrases = text.Split ('\"');
+
+ //Make it possible to search for "whole phrases"
+ List<string> wordsList = new List<string> (phrases);
+ int count = wordsList.Count;
+ for (int i = 0; i < count; i += 1) {
+ string part = wordsList[i];
+ foreach (string s in part.Split (' ', '\t', '\n'))
+ if (s.Length > 0)
+ wordsList.Add (s);
+ wordsList.RemoveAt (i);
+ count--;
+ }
+
+ return wordsList.ToArray ();
+ }
-
bool CheckNoteHasMatch (Note note, string [] encoded_words, bool match_case)
{
string note_text = note.XmlContent;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]