about summary refs log tree commit diff stats
path: root/edit/011-errors.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-08-22 09:19:40 -0700
committerKartik K. Agaram <vc@akkartik.com>2017-08-22 09:19:40 -0700
commitfc97f6670d3094f1a5f213ec3a3f7134a14ddadd (patch)
tree0cf8373544ec02543ac5d89b1cc58cf28a6e1c0c /edit/011-errors.mu
parent115c6080017e9fa4b47292b5f58fbcef26daf4c4 (diff)
downloadmu-fc97f6670d3094f1a5f213ec3a3f7134a14ddadd.tar.gz
3982 - bugfix: clear old recipe errors on F4
This regression was introduced by commit 3902 in June.

Making this commit clean took the last 4 commits of reorganizing.
Diffstat (limited to 'edit/011-errors.mu')
-rw-r--r--edit/011-errors.mu59
1 files changed, 59 insertions, 0 deletions
diff --git a/edit/011-errors.mu b/edit/011-errors.mu
index 9625f8e1..8db2c583 100644
--- a/edit/011-errors.mu
+++ b/edit/011-errors.mu
@@ -23,7 +23,15 @@ def! update-recipes env:&:environment, resources:&:resources, screen:&:screen ->
   errors-found? <- copy 0/false
 ]
 
+after <begin-run-sandboxes-on-F4> [
+  old-recipe-errors:text <- get *env, recipe-errors:offset
+]
 before <end-run-sandboxes-on-F4> [
+  # if there were recipe errors before, check if we can clear them
+  {
+    break-unless old-recipe-errors
+    screen <- render-recipes screen, env, render
+  }
   screen <- render-recipe-errors env, screen
 ]
 
@@ -562,6 +570,57 @@ scenario run-shows-errors-every-time [
   ]
 ]
 
+scenario run-hides-errors [
+  local-scope
+  trace-until 100/app  # trace too long
+  assume-screen 100/width, 15/height
+  # try to run a file with an error
+  assume-resources [
+    [lesson/recipes.mu] <- [
+      |recipe foo [|
+      |  local-scope|
+      |  x:num <- copy y:num|
+      |]|
+    ]
+  ]
+  env:&:environment <- new-programming-environment resources, screen, [foo]
+  render-all screen, env, render
+  assume-console [
+    press F4
+  ]
+  event-loop screen, console, env, resources
+  screen-should-contain [
+    .  errors found                                                                   run (F4)           .
+    .recipe foo [                                      ┊foo                                              .
+    .  local-scope                                     ┊─────────────────────────────────────────────────.
+    .  x:num <- copy y:num                             ┊                                                 .
+    .]                                                 ┊                                                 .
+    .foo: tried to read ingredient 'y' in 'x:num <- co↩┊                                                 .
+    .py y:num' but it hasn't been written to yet       ┊                                                 .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
+    .                                                  ┊                                                 .
+  ]
+  # fix the error, hit F4
+  assume-console [
+    left-click 3, 16
+    press ctrl-k
+    type [0]
+    press F4
+  ]
+  event-loop screen, console, env, resources
+  # no error anymore
+  screen-should-contain [
+    .                                                                                 run (F4)           .
+    .recipe foo [                                      ┊                                                 .
+    .  local-scope                                     ┊─────────────────────────────────────────────────.
+    .  x:num <- copy 0                                 ┊0   edit       copy       to recipe    delete    .
+    .]                                                 ┊foo                                              .
+    .                                                  ┊─────────────────────────────────────────────────.
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
+    .                                                  ┊                                                 .
+  ]
+]
+
 scenario run-instruction-and-print-errors [
   local-scope
   trace-until 100/app  # trace too long