From 07a6418389a6c36c0fe9cded6e585fb013ec90e1 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 1 Feb 2016 13:29:46 -0800 Subject: 2623 - bugfix: editing sandboxes If you restore 2 sandboxes, the first render was setting response-starting-row-on-screen on both, without ever rendering a response. If the lower sandbox contained a print and rendered the screen instead of the response, the original response-starting-row-on-screen was never reset. If the process of running the sandboxes caused the lower sandbox's title bar to move below the now-stale response-starting-row-on-screen[1], editing the lower sandbox no longer works. [1] (Either because the upper sandbox prints to screen as well (causing the first F4 to move the lower sandbox down by several lines), or because a fresh sandbox is created with several lines before the first F4 is hit.) Current solution: never set response-starting-row-on-screen during reload (or otherwise when there's no response). This is hard to test right now because 'restore' is not a tested interface, and I can't come up with another situation where the response-starting-row-on-screen goes stale. So I'm now trying to keep all changes to response-starting-row-on-screen close together. Another idea is to add a check that the click row lies below the response-starting row *and* above the start of the next sandbox. (But what if there's no next sandbox?) (This bug is really a regression, introduced last Sep in 2163.) --- 029tools.cc | 2 +- edit/005-sandbox.mu | 6 +----- edit/008-sandbox-test.mu | 13 +++++++++++++ edit/010-warnings.mu | 1 + sandbox/005-sandbox.mu | 9 +++------ sandbox/008-sandbox-test.mu | 13 +++++++++++++ sandbox/010-warnings.mu | 1 + 7 files changed, 33 insertions(+), 12 deletions(-) diff --git a/029tools.cc b/029tools.cc index fb52c7b4..7090abda 100644 --- a/029tools.cc +++ b/029tools.cc @@ -324,6 +324,6 @@ case _LOG: { for (long long int i = 0; i < SIZE(current_instruction().ingredients); ++i) { out << print_mu(current_instruction().ingredients.at(i), ingredients.at(i)); } - LOG << out.str() << "(length: " << get(Recipe_ordinal, "length") << '/' << contains_key(Recipe, get(Recipe_ordinal, "length")) << ")\n"; + LOG << out.str() << '\n'; break; } diff --git a/edit/005-sandbox.mu b/edit/005-sandbox.mu index 244c24f6..a5a0d239 100644 --- a/edit/005-sandbox.mu +++ b/edit/005-sandbox.mu @@ -36,7 +36,6 @@ container sandbox-data [ # constraint: will be 0 for sandboxes at positions before env.render-from starting-row-on-screen:number code-ending-row-on-screen:number # past end of code - response-starting-row-on-screen:number screen:address:shared:screen # prints in the sandbox go here next-sandbox:address:shared:sandbox-data ] @@ -301,7 +300,6 @@ recipe render-sandboxes screen:address:shared:screen, sandbox:address:shared:san code-ending-row:address:number <- get-address *sandbox, code-ending-row-on-screen:offset *code-ending-row <- copy row # render sandbox warnings, screen or response, in that order - response-starting-row:address:number <- get-address *sandbox, response-starting-row-on-screen:offset sandbox-response:address:shared:array:character <- get *sandbox, response:offset { @@ -312,7 +310,6 @@ recipe render-sandboxes screen:address:shared:screen, sandbox:address:shared:san } { break-unless empty-screen? - *response-starting-row <- copy row row, screen <- render screen, sandbox-response, left, right, 245/grey, row } @@ -329,8 +326,7 @@ recipe render-sandboxes screen:address:shared:screen, sandbox:address:shared:san *tmp <- copy 0 tmp:address:number <- get-address *sandbox, code-ending-row-on-screen:offset *tmp <- copy 0 - tmp:address:number <- get-address *sandbox, response-starting-row-on-screen:offset - *tmp <- copy 0 + } # draw next sandbox next-sandbox:address:shared:sandbox-data <- get *sandbox, next-sandbox:offset diff --git a/edit/008-sandbox-test.mu b/edit/008-sandbox-test.mu index fb6dc260..347980aa 100644 --- a/edit/008-sandbox-test.mu +++ b/edit/008-sandbox-test.mu @@ -111,6 +111,11 @@ after [ } ] +# this requires tracking where responses begin for every sandbox +container sandbox-data [ + response-starting-row-on-screen:number +] + recipe find-click-in-sandbox-output env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients @@ -156,6 +161,8 @@ recipe toggle-expected-response sandbox:address:shared:sandbox-data -> sandbox:a after [ { break-unless sandbox-response + response-starting-row:address:number <- get-address *sandbox, response-starting-row-on-screen:offset + *response-starting-row <- copy row expected-response:address:shared:array:character <- get *sandbox, expected-response:offset break-unless expected-response # fall-through to print in grey response-is-expected?:boolean <- equal expected-response, sandbox-response @@ -170,3 +177,9 @@ after [ jump +render-sandbox-end:label } ] + +before [ + $log sandbox, [resetting response starting row] + tmp:address:number <- get-address *sandbox, response-starting-row-on-screen:offset + *tmp <- copy 0 +] diff --git a/edit/010-warnings.mu b/edit/010-warnings.mu index 5220ad3e..8771a869 100644 --- a/edit/010-warnings.mu +++ b/edit/010-warnings.mu @@ -117,6 +117,7 @@ after [ { sandbox-warnings:address:shared:array:character <- get *sandbox, warnings:offset break-unless sandbox-warnings + response-starting-row:address:number <- get-address *sandbox, response-starting-row-on-screen:offset *response-starting-row <- copy 0 # no response row, screen <- render screen, sandbox-warnings, left, right, 1/red, row # don't try to print anything more for this sandbox diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu index 929716a1..690ab22c 100644 --- a/sandbox/005-sandbox.mu +++ b/sandbox/005-sandbox.mu @@ -23,7 +23,6 @@ container sandbox-data [ # constraint: will be 0 for sandboxes at positions before env.render-from starting-row-on-screen:number code-ending-row-on-screen:number # past end of code - response-starting-row-on-screen:number screen:address:shared:screen # prints in the sandbox go here next-sandbox:address:shared:sandbox-data ] @@ -289,7 +288,6 @@ recipe render-sandboxes screen:address:shared:screen, sandbox:address:shared:san code-ending-row:address:number <- get-address *sandbox, code-ending-row-on-screen:offset *code-ending-row <- copy row # render sandbox warnings, screen or response, in that order - response-starting-row:address:number <- get-address *sandbox, response-starting-row-on-screen:offset sandbox-response:address:shared:array:character <- get *sandbox, response:offset { @@ -300,13 +298,12 @@ recipe render-sandboxes screen:address:shared:screen, sandbox:address:shared:san } { break-unless empty-screen? - *response-starting-row <- copy row row, screen <- render screen, sandbox-response, left, right, 245/grey, row } +render-sandbox-end at-bottom?:boolean <- greater-or-equal row, screen-height - reply-if at-bottom?, row/same-as-ingredient:4, screen/same-as-ingredient:0 + reply-if at-bottom? # draw solid line after sandbox draw-horizontal screen, row, left, right, 9473/horizontal-double } @@ -317,8 +314,7 @@ recipe render-sandboxes screen:address:shared:screen, sandbox:address:shared:san *tmp <- copy 0 tmp:address:number <- get-address *sandbox, code-ending-row-on-screen:offset *tmp <- copy 0 - tmp:address:number <- get-address *sandbox, response-starting-row-on-screen:offset - *tmp <- copy 0 + } # draw next sandbox next-sandbox:address:shared:sandbox-data <- get *sandbox, next-sandbox:offset @@ -429,6 +425,7 @@ recipe render-screen screen:address:shared:screen, sandbox-screen:address:shared ] scenario run-updates-results [ + trace-until 100/app # trace too long assume-screen 50/width, 12/height # define a recipe (no indent for the 'add' line below so column numbers are more obvious) 1:address:shared:array:character <- new [ diff --git a/sandbox/008-sandbox-test.mu b/sandbox/008-sandbox-test.mu index d08bb890..c5695610 100644 --- a/sandbox/008-sandbox-test.mu +++ b/sandbox/008-sandbox-test.mu @@ -110,6 +110,11 @@ after [ } ] +# this requires tracking where responses begin for every sandbox +container sandbox-data [ + response-starting-row-on-screen:number +] + recipe find-click-in-sandbox-output env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients @@ -155,6 +160,8 @@ recipe toggle-expected-response sandbox:address:shared:sandbox-data -> sandbox:a after [ { break-unless sandbox-response + response-starting-row:address:number <- get-address *sandbox, response-starting-row-on-screen:offset + *response-starting-row <- copy row expected-response:address:shared:array:character <- get *sandbox, expected-response:offset break-unless expected-response # fall-through to print in grey response-is-expected?:boolean <- equal expected-response, sandbox-response @@ -169,3 +176,9 @@ after [ jump +render-sandbox-end:label } ] + +before [ + $log sandbox, [resetting response starting row] + tmp:address:number <- get-address *sandbox, response-starting-row-on-screen:offset + *tmp <- copy 0 +] diff --git a/sandbox/010-warnings.mu b/sandbox/010-warnings.mu index a20e306d..8ceb88bb 100644 --- a/sandbox/010-warnings.mu +++ b/sandbox/010-warnings.mu @@ -118,6 +118,7 @@ after [ { sandbox-warnings:address:shared:array:character <- get *sandbox, warnings:offset break-unless sandbox-warnings + response-starting-row:address:number <- get-address *sandbox, response-starting-row-on-screen:offset *response-starting-row <- copy 0 # no response { break-unless env -- cgit 1.4.1-2-gfad0