tuned;
authorwenzelm
Sun Apr 13 21:51:49 2014 +0200 (2014-04-13 ago)
changeset 56565927dff80d0df
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
     1.1 --- a/src/Tools/jEdit/src/completion_popup.scala	Sun Apr 13 21:43:25 2014 +0200
     1.2 +++ b/src/Tools/jEdit/src/completion_popup.scala	Sun Apr 13 21:51:49 2014 +0200
     1.3 @@ -200,11 +200,10 @@
     1.4              for {
     1.5                spell_range <- rendering.spell_checker_point(caret_range)
     1.6                text <- JEdit_Lib.try_get_text(text_area.getBuffer, spell_range)
     1.7 -              caret_range0 = caret_range - spell_range.start
     1.8 -              Text.Info(range0, word) <-
     1.9 -                Spell_Checker.marked_words(text,
    1.10 -                  info => info.range.overlaps(caret_range0)).headOption
    1.11 -            } yield Text.Info(range0 + spell_range.start, word)
    1.12 +              info <-
    1.13 +                Spell_Checker.marked_words(spell_range.start, text,
    1.14 +                  info => info.range.overlaps(caret_range)).headOption
    1.15 +            } yield info
    1.16  
    1.17            result match {
    1.18              case Some(Text.Info(range, original)) =>
     2.1 --- a/src/Tools/jEdit/src/rich_text_area.scala	Sun Apr 13 21:43:25 2014 +0200
     2.2 +++ b/src/Tools/jEdit/src/rich_text_area.scala	Sun Apr 13 21:51:49 2014 +0200
     2.3 @@ -320,10 +320,10 @@
     2.4              // spell checker
     2.5              for {
     2.6                spell_checker <- PIDE.spell_checker.get
     2.7 -              range0 <- rendering.spell_checker_ranges(line_range)
     2.8 -              text <- JEdit_Lib.try_get_text(buffer, range0)
     2.9 -              info <- spell_checker.marked_words(text)
    2.10 -              r <- JEdit_Lib.gfx_range(text_area, info.range + range0.start)
    2.11 +              spell_range <- rendering.spell_checker_ranges(line_range)
    2.12 +              text <- JEdit_Lib.try_get_text(buffer, spell_range)
    2.13 +              info <- spell_checker.marked_words(spell_range.start, text)
    2.14 +              r <- JEdit_Lib.gfx_range(text_area, info.range)
    2.15              } {
    2.16                gfx.setColor(rendering.spell_checker_color)
    2.17                val y0 = r.y + ((fm.getAscent + 4) min (line_height - 2))
     3.1 --- a/src/Tools/jEdit/src/spell_checker.scala	Sun Apr 13 21:43:25 2014 +0200
     3.2 +++ b/src/Tools/jEdit/src/spell_checker.scala	Sun Apr 13 21:51:49 2014 +0200
     3.3 @@ -22,7 +22,8 @@
     3.4  {
     3.5    /* marked words within text */
     3.6  
     3.7 -  def marked_words(text: String, mark: Text.Info[String] => Boolean): List[Text.Info[String]] =
     3.8 +  def marked_words(base: Text.Offset, text: String, mark: Text.Info[String] => Boolean)
     3.9 +    : List[Text.Info[String]] =
    3.10    {
    3.11      val result = new mutable.ListBuffer[Text.Info[String]]
    3.12      var offset = 0
    3.13 @@ -47,7 +48,7 @@
    3.14        scan(c => Character.isLetterOrDigit(c) || apostrophe(c))
    3.15        val stop = offset
    3.16        if (stop - start >= 2) {
    3.17 -        val info = Text.Info(Text.Range(start, stop), text.substring(start, stop))
    3.18 +        val info = Text.Info(Text.Range(base + start, base + stop), text.substring(start, stop))
    3.19          if (mark(info)) result += info
    3.20        }
    3.21      }
    3.22 @@ -167,8 +168,8 @@
    3.23      m.invoke(dict, word).asInstanceOf[java.util.List[AnyRef]].toArray.toList.map(_.toString)
    3.24    }
    3.25  
    3.26 -  def marked_words(text: String): List[Text.Info[String]] =
    3.27 -    Spell_Checker.marked_words(text, info => !check(info.info))
    3.28 +  def marked_words(base: Text.Offset, text: String): List[Text.Info[String]] =
    3.29 +    Spell_Checker.marked_words(base, text, info => !check(info.info))
    3.30  }
    3.31  
    3.32