From fc97f6670d3094f1a5f213ec3a3f7134a14ddadd Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 22 Aug 2017 09:19:40 -0700 Subject: 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. --- edit/005-sandbox.mu | 1 + edit/011-errors.mu | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/edit/005-sandbox.mu b/edit/005-sandbox.mu index 16754946..869b4ca4 100644 --- a/edit/005-sandbox.mu +++ b/edit/005-sandbox.mu @@ -129,6 +129,7 @@ after [ do-run?:bool <- equal k, 65532/F4 break-unless do-run? screen <- update-status screen, [running... ], 245/grey + error?:bool <- run-sandboxes env, resources, screen # we could just render-all, but we do some work to minimize the number of prints to screen 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 [ + old-recipe-errors:text <- get *env, recipe-errors:offset +] before [ + # 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 -- cgit 1.4.1-2-gfad0