src/Tools/jEdit/src/jedit_editor.scala
changeset 54528 842adea880a4
parent 54522 761be40990f1
child 54531 8330faaeebd5
     1.1 --- a/src/Tools/jEdit/src/jedit_editor.scala	Wed Nov 20 12:04:06 2013 +0100
     1.2 +++ b/src/Tools/jEdit/src/jedit_editor.scala	Wed Nov 20 12:24:54 2013 +0100
     1.3 @@ -63,11 +63,13 @@
     1.4      Swing_Thread.require()
     1.5  
     1.6      val text_area = view.getTextArea
     1.7 +    val buffer = view.getBuffer
     1.8 +
     1.9      PIDE.document_view(text_area) match {
    1.10        case Some(doc_view) =>
    1.11          val node = snapshot.version.nodes(doc_view.model.node_name)
    1.12          val caret = snapshot.revert(text_area.getCaretPosition)
    1.13 -        if (caret < text_area.getBuffer.getLength) {
    1.14 +        if (caret < buffer.getLength) {
    1.15            val caret_commands = node.command_range(caret)
    1.16            if (caret_commands.hasNext) {
    1.17              val (cmd0, _) = caret_commands.next
    1.18 @@ -76,7 +78,15 @@
    1.19            else None
    1.20          }
    1.21          else node.commands.reverse.iterator.find(cmd => !cmd.is_ignored)
    1.22 -      case None => None
    1.23 +      case None =>
    1.24 +        PIDE.document_model(buffer) match {
    1.25 +          case Some(model) if !model.node_name.is_theory =>
    1.26 +            snapshot.version.nodes.thy_load_commands(model.node_name) match {
    1.27 +              case cmd :: _ => Some(cmd)
    1.28 +              case Nil => None
    1.29 +            }
    1.30 +          case _ => None
    1.31 +        }
    1.32      }
    1.33    }
    1.34