closing 'qed' or '}' is outside of fold;
authorwenzelm
Tue, 12 Jul 2016 13:26:39 +0200
changeset 63458 723f9c673c1c
parent 63457 be6ceddff102
child 63459 8d68204d97d7
closing 'qed' or '}' is outside of fold;
src/Pure/Isar/outer_syntax.scala
--- a/src/Pure/Isar/outer_syntax.scala	Tue Jul 12 12:58:53 2016 +0200
+++ b/src/Pure/Isar/outer_syntax.scala	Tue Jul 12 13:26:39 2016 +0200
@@ -148,8 +148,20 @@
     val improper1 = tokens.forall(_.is_improper)
     val command1 = tokens.exists(_.is_command)
 
+    val command_depth =
+      tokens.iterator.filter(_.is_proper).toStream.headOption match {
+        case Some(tok) =>
+          if (keywords.is_command(tok, Keyword.QED_BLOCK == _))
+            Some(structure.after_span_depth - 2)
+          else if (keywords.is_command(tok, Keyword.PRF_CLOSE == _))
+            Some(structure.after_span_depth - 1)
+          else None
+        case None => None
+      }
+
     val depth1 =
       if (tokens.exists(keywords.is_command(_, Keyword.theory))) 0
+      else if (command_depth.isDefined) command_depth.get
       else if (command1) structure.after_span_depth
       else structure.span_depth
 
@@ -161,7 +173,8 @@
             else if (keywords.is_command(tok, Keyword.theory)) (1, 0)
             else if (keywords.is_command(tok, Keyword.proof_open)) (y + 2, y + 1)
             else if (keywords.is_command(tok, Keyword.PRF_BLOCK == _)) (y + 2, y + 1)
-            else if (keywords.is_command(tok, Keyword.QED_BLOCK == _)) (y + 1, y - 2)
+            else if (keywords.is_command(tok, Keyword.QED_BLOCK == _)) (y - 1, y - 2)
+            else if (keywords.is_command(tok, Keyword.PRF_CLOSE == _)) (y, y - 1)
             else if (keywords.is_command(tok, Keyword.proof_close)) (y + 1, y - 1)
             else if (keywords.is_command(tok, Keyword.qed_global)) (1, 0)
             else (x, y)