src/Tools/jEdit/src/rendering.scala
changeset 55688 767edb2c1e4e
parent 55687 78c83cd477c1
child 55689 13b58baf994b
     1.1 --- a/src/Tools/jEdit/src/rendering.scala	Sun Feb 23 14:39:51 2014 +0100
     1.2 +++ b/src/Tools/jEdit/src/rendering.scala	Sun Feb 23 15:35:19 2014 +0100
     1.3 @@ -273,35 +273,39 @@
     1.4  
     1.5    /* completion */
     1.6  
     1.7 +  def completion_range(caret: Text.Offset): Option[Text.Range] =
     1.8 +    if (!snapshot.is_outdated) {
     1.9 +      snapshot.select(Text.Range(caret - 1, caret + 1), Rendering.completion_names_elements, _ =>
    1.10 +        {
    1.11 +          case Completion.Names.Info(names) => Some(names.range)
    1.12 +          case _ => None
    1.13 +        }).headOption.map(_.info)
    1.14 +    }
    1.15 +    else None
    1.16 +
    1.17    def completion_names(caret: Text.Offset): Option[Completion.Names] =
    1.18      if (caret > 0 && !snapshot.is_outdated)
    1.19      {
    1.20 -      val result =
    1.21 -        snapshot.select(Text.Range(caret - 1, caret + 1),
    1.22 -          Rendering.completion_names_elements, _ =>
    1.23 -          {
    1.24 -            case Completion.Names.Info(names) => Some(names)
    1.25 -            case _ => None
    1.26 -          })
    1.27 -      result.headOption.map(_.info)
    1.28 +      snapshot.select(Text.Range(caret - 1, caret + 1), Rendering.completion_names_elements, _ =>
    1.29 +        {
    1.30 +          case Completion.Names.Info(names) => Some(names)
    1.31 +          case _ => None
    1.32 +        }).headOption.map(_.info)
    1.33      }
    1.34      else None
    1.35  
    1.36    def completion_context(caret: Text.Offset): Option[Completion.Context] =
    1.37      if (caret > 0) {
    1.38 -      val result =
    1.39 -        snapshot.select(Text.Range(caret - 1, caret + 1),
    1.40 -          Rendering.completion_context_elements, _ =>
    1.41 -          {
    1.42 -            case Text.Info(_, elem)
    1.43 -            if elem.name == Markup.ML_STRING || elem.name == Markup.ML_COMMENT =>
    1.44 -              Some(Completion.Context.ML_inner)
    1.45 -            case Text.Info(_, XML.Elem(Markup.Language(language, symbols, antiquotes), _)) =>
    1.46 -              Some(Completion.Context(language, symbols, antiquotes))
    1.47 -            case Text.Info(_, _) =>
    1.48 -              Some(Completion.Context.inner)
    1.49 -          })
    1.50 -      result.headOption.map(_.info)
    1.51 +      snapshot.select(Text.Range(caret - 1, caret + 1), Rendering.completion_context_elements, _ =>
    1.52 +        {
    1.53 +          case Text.Info(_, elem)
    1.54 +          if elem.name == Markup.ML_STRING || elem.name == Markup.ML_COMMENT =>
    1.55 +            Some(Completion.Context.ML_inner)
    1.56 +          case Text.Info(_, XML.Elem(Markup.Language(language, symbols, antiquotes), _)) =>
    1.57 +            Some(Completion.Context(language, symbols, antiquotes))
    1.58 +          case Text.Info(_, _) =>
    1.59 +            Some(Completion.Context.inner)
    1.60 +        }).headOption.map(_.info)
    1.61      }
    1.62      else None
    1.63