[tomboy] Watchers.cs: fix URL highlighting with multibytes in the text
- From: Alex Tereschenko <alexter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tomboy] Watchers.cs: fix URL highlighting with multibytes in the text
- Date: Sat, 27 May 2017 18:22:26 +0000 (UTC)
commit 1c745ebc71e3c540f4384e5097f337dd0d4a03f3
Author: Alex Tereschenko <frozen and blue gmail com>
Date: Sat May 27 20:08:07 2017 +0200
Watchers.cs: fix URL highlighting with multibytes in the text
Closes #45.
Signed-off-by: Alex Tereschenko <frozen and blue gmail com>
Tomboy/Watchers.cs | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/Tomboy/Watchers.cs b/Tomboy/Watchers.cs
index 2f79385..b5f2191 100644
--- a/Tomboy/Watchers.cs
+++ b/Tomboy/Watchers.cs
@@ -542,6 +542,7 @@ namespace Tomboy
Buffer.RemoveTag (Note.TagTable.UrlTag, start, end);
+ Gtk.TextIter searchiter = start;
for (Match match = regex.Match (start.GetSlice (end));
match.Success;
match = match.NextMatch ()) {
@@ -553,13 +554,13 @@ namespace Tomboy
group.Index);
*/
- Gtk.TextIter start_cpy = start;
- start_cpy.ForwardChars (group.Index);
-
- end = start_cpy;
- end.ForwardChars (group.Length);
+ // Use the ForwardSearch instead of group's Index to account for multibyte
chars in the text.
+ // We'll search using the exact match value within provided boundaries.
+ Gtk.TextIter startiter, enditer;
+ searchiter.ForwardSearch (group.Value, Gtk.TextSearchFlags.VisibleOnly, out
startiter, out enditer, end);
+ searchiter = enditer;
- Buffer.ApplyTag (Note.TagTable.UrlTag, start_cpy, end);
+ Buffer.ApplyTag (Note.TagTable.UrlTag, startiter, enditer);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]