From 691c6739afcc734f4e1a6d0c560f2a6efb5bec32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Wed, 20 May 2020 11:59:18 +0200 Subject: [PATCH] [apps/variable_box_controller] Fix loadCurrentVariablesInScript Scenario: write the script: def squares(): for i in range(660): forward(L)lo) Put the cursor right of "lo" and press backspace. --- apps/code/variable_box_controller.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/code/variable_box_controller.cpp b/apps/code/variable_box_controller.cpp index d99e7aa9c..aba82d4a5 100644 --- a/apps/code/variable_box_controller.cpp +++ b/apps/code/variable_box_controller.cpp @@ -624,8 +624,13 @@ void VariableBoxController::loadCurrentVariablesInScript(const char * scriptCont * nameLength are temporary variables that will be overriden when the * lexer continues lexing or is destroyed. * This was found from stepping in the code and trying. */ + /* TODO: Try to understand what is happening with tokenInText and + * remove this trick.*/ + while (*tokenInText == ' ') { + tokenInText++; + } for (int i = 0; i < 3; i++) { - if (strncmp(tokenInText, name, nameLength) != 0) { + if (strncmp(tokenInText, name, nameLength) != 0 && tokenInText > scriptContent) { tokenInText--; } else { break;