[gnote] * Fix offsets on WikiWord (similar to bug #579225)



commit 468ea10fe32a96256d9e7c52737f0cae2c778af7
Author: Hubert Figuiere <hub figuiere net>
Date:   Sat Apr 18 01:19:00 2009 -0400

      * Fix offsets on WikiWord (similar to bug #579225)
---
 NEWS             |    1 +
 src/watchers.cpp |   11 ++++++-----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/NEWS b/NEWS
index 3a71893..056611e 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Fixes:
     (Close #579240)
   * Fix wrongly highlighted URLs and a crash when inserting in some situation.
     (Close #579225)
+  * Fix offsets on WikiWord (similar to bug #579225)
 
 Translations:
 
diff --git a/src/watchers.cpp b/src/watchers.cpp
index 5cbf0f2..0166d9a 100644
--- a/src/watchers.cpp
+++ b/src/watchers.cpp
@@ -1041,19 +1041,20 @@ namespace gnote {
     boost::sregex_iterator m1(s.begin(), s.end(), m_regex);
     boost::sregex_iterator m2;
     while(m1 != m2) {
-      /// TODO iterator throught the WHOLE match
       const boost::sub_match<std::string::const_iterator> & match = (*m1)[1];
 
       if (match.matched && !is_patronymic_name (match.str())) {
 
-        DBG_OUT("Highlighting wikiword: '%s' at offset %d",
-                match.str().c_str(), (match.first - s.begin()));
       
         Gtk::TextIter start_cpy = start;
-        start_cpy.forward_chars (match.first - s.begin());
+        Glib::ustring segment(std::string(s.c_str(), match.first - s.begin()));
+        start_cpy.forward_chars (segment.length());
+        DBG_OUT("Highlighting wikiword: '%s' at offset %d",
+                match.str().c_str(), segment.length());
 
         end = start_cpy;
-        end.forward_chars (match.length());
+        segment = match.str();
+        end.forward_chars (segment.length());
 
         if (!manager().find (match.str())) {
           get_buffer()->apply_tag (m_broken_link_tag, start_cpy, end);



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