tuned;
authorwenzelm
Sun, 13 Apr 2014 21:51:49 +0200
changeset 56565 927dff80d0df
parent 56564 94c55cc73747
child 56566 46a4c6b688c9
tuned;
src/Tools/jEdit/src/completion_popup.scala
src/Tools/jEdit/src/rich_text_area.scala
src/Tools/jEdit/src/spell_checker.scala
--- a/src/Tools/jEdit/src/completion_popup.scala	Sun Apr 13 21:43:25 2014 +0200
+++ b/src/Tools/jEdit/src/completion_popup.scala	Sun Apr 13 21:51:49 2014 +0200
@@ -200,11 +200,10 @@
             for {
               spell_range <- rendering.spell_checker_point(caret_range)
               text <- JEdit_Lib.try_get_text(text_area.getBuffer, spell_range)
-              caret_range0 = caret_range - spell_range.start
-              Text.Info(range0, word) <-
-                Spell_Checker.marked_words(text,
-                  info => info.range.overlaps(caret_range0)).headOption
-            } yield Text.Info(range0 + spell_range.start, word)
+              info <-
+                Spell_Checker.marked_words(spell_range.start, text,
+                  info => info.range.overlaps(caret_range)).headOption
+            } yield info
 
           result match {
             case Some(Text.Info(range, original)) =>
--- a/src/Tools/jEdit/src/rich_text_area.scala	Sun Apr 13 21:43:25 2014 +0200
+++ b/src/Tools/jEdit/src/rich_text_area.scala	Sun Apr 13 21:51:49 2014 +0200
@@ -320,10 +320,10 @@
             // spell checker
             for {
               spell_checker <- PIDE.spell_checker.get
-              range0 <- rendering.spell_checker_ranges(line_range)
-              text <- JEdit_Lib.try_get_text(buffer, range0)
-              info <- spell_checker.marked_words(text)
-              r <- JEdit_Lib.gfx_range(text_area, info.range + range0.start)
+              spell_range <- rendering.spell_checker_ranges(line_range)
+              text <- JEdit_Lib.try_get_text(buffer, spell_range)
+              info <- spell_checker.marked_words(spell_range.start, text)
+              r <- JEdit_Lib.gfx_range(text_area, info.range)
             } {
               gfx.setColor(rendering.spell_checker_color)
               val y0 = r.y + ((fm.getAscent + 4) min (line_height - 2))
--- a/src/Tools/jEdit/src/spell_checker.scala	Sun Apr 13 21:43:25 2014 +0200
+++ b/src/Tools/jEdit/src/spell_checker.scala	Sun Apr 13 21:51:49 2014 +0200
@@ -22,7 +22,8 @@
 {
   /* marked words within text */
 
-  def marked_words(text: String, mark: Text.Info[String] => Boolean): List[Text.Info[String]] =
+  def marked_words(base: Text.Offset, text: String, mark: Text.Info[String] => Boolean)
+    : List[Text.Info[String]] =
   {
     val result = new mutable.ListBuffer[Text.Info[String]]
     var offset = 0
@@ -47,7 +48,7 @@
       scan(c => Character.isLetterOrDigit(c) || apostrophe(c))
       val stop = offset
       if (stop - start >= 2) {
-        val info = Text.Info(Text.Range(start, stop), text.substring(start, stop))
+        val info = Text.Info(Text.Range(base + start, base + stop), text.substring(start, stop))
         if (mark(info)) result += info
       }
     }
@@ -167,8 +168,8 @@
     m.invoke(dict, word).asInstanceOf[java.util.List[AnyRef]].toArray.toList.map(_.toString)
   }
 
-  def marked_words(text: String): List[Text.Info[String]] =
-    Spell_Checker.marked_words(text, info => !check(info.info))
+  def marked_words(base: Text.Offset, text: String): List[Text.Info[String]] =
+    Spell_Checker.marked_words(base, text, info => !check(info.info))
 }