[Monodevelop-patches-list] r2072 - in trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor: . Search Search/SearchStrategy

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Mon Dec 13 15:51:04 EST 2004


Author: lluis
Date: 2004-12-13 15:51:04 -0500 (Mon, 13 Dec 2004)
New Revision: 2072

Modified:
   trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/ChangeLog
   trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Search/SearchReplaceUtilities.cs
   trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Search/SearchStrategy/BruteForceSearchStrategy.cs
Log:
2004-12-13  Lluis Sanchez Gual  <lluis at novell.com>

	* Search/SearchReplaceUtilities.cs: 
	* Search/SearchStrategy/BruteForceSearchStrategy.cs: Word boundaries
	can be white spaces or punctuation chars. Added new method 
	IsWordSeparator that checks both.



Modified: trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/ChangeLog	2004-12-13 20:39:04 UTC (rev 2071)
+++ trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/ChangeLog	2004-12-13 20:51:04 UTC (rev 2072)
@@ -1,3 +1,10 @@
+2004-12-13  Lluis Sanchez Gual  <lluis at novell.com>
+
+	* Search/SearchReplaceUtilities.cs: 
+	* Search/SearchStrategy/BruteForceSearchStrategy.cs: Word boundaries
+	can be white spaces or punctuation chars. Added new method 
+	IsWordSeparator that checks both.
+
 2004-12-11  Alexandre Gomes <alexmipego at hotmail.com>
 	
 	* Gui/SourceEditorDisplayBinding.cs: Added support for the already

Modified: trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Search/SearchReplaceUtilities.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Search/SearchReplaceUtilities.cs	2004-12-13 20:39:04 UTC (rev 2071)
+++ trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Search/SearchReplaceUtilities.cs	2004-12-13 20:51:04 UTC (rev 2072)
@@ -25,20 +25,24 @@
 			}
 		}
 		
+		public static bool IsWordSeparator (char c)
+		{
+			return Char.IsWhiteSpace (c) || (Char.IsPunctuation (c) && c != '_');
+		}
 		
 		public static bool IsWholeWordAt(SourceEditorBuffer document, int offset, int length)
 		{
-			return (offset - 1 < 0 || Char.IsWhiteSpace(document.GetCharAt(offset - 1))) &&
-			       (offset + length + 1 >= document.Length || Char.IsWhiteSpace(document.GetCharAt(offset + length)));
+			return (offset - 1 < 0 || IsWordSeparator (document.GetCharAt(offset - 1))) &&
+			       (offset + length + 1 >= document.Length || IsWordSeparator (document.GetCharAt(offset + length)));
 		}
 
 		public static bool IsWholeWordAt (ITextIterator it, int length)
 		{
 			char c = it.GetCharRelative (-1);
-			if (c != char.MinValue && !Char.IsWhiteSpace (c)) return false;
+			if (c != char.MinValue && !IsWordSeparator (c)) return false;
 			
 			c = it.GetCharRelative (length);
-			return (c == char.MinValue || Char.IsWhiteSpace (c));
+			return (c == char.MinValue || IsWordSeparator (c));
 		}
 
 		/*public static int CalcCurrentOffset(IDocument document) 

Modified: trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Search/SearchStrategy/BruteForceSearchStrategy.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Search/SearchStrategy/BruteForceSearchStrategy.cs	2004-12-13 20:39:04 UTC (rev 2071)
+++ trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Search/SearchStrategy/BruteForceSearchStrategy.cs	2004-12-13 20:51:04 UTC (rev 2072)
@@ -50,7 +50,7 @@
 								if (searchWord) {
 									int curp = textIterator.Position;
 									bool endw = !textIterator.MoveAhead (1);
-									endw = endw || Char.IsWhiteSpace (textIterator.Current);
+									endw = endw || SearchReplaceUtilities.IsWordSeparator (textIterator.Current);
 									textIterator.Position = curp;
 									if (endw) return startPositions[n];
 								}
@@ -83,7 +83,7 @@
 					compareIndex [freePos] = 1;
 					startPositions [freePos] = textIterator.Position;
 				}
-				wasWordStart = Char.IsWhiteSpace (c);
+				wasWordStart = SearchReplaceUtilities.IsWordSeparator (c);
 			}
 			
 			return -1;




More information about the Monodevelop-patches-list mailing list