From 0428c814e8f93ca3ef400826b4f2ccab222dab19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Thu, 2 Apr 2020 09:56:00 +0200 Subject: [PATCH] [apps/code] Fix array shifting --- apps/code/variable_box_controller.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/code/variable_box_controller.cpp b/apps/code/variable_box_controller.cpp index e4437a2cd..8c2184dfd 100644 --- a/apps/code/variable_box_controller.cpp +++ b/apps/code/variable_box_controller.cpp @@ -346,7 +346,6 @@ importCurrent: * MP_TOKEN_NAME that complete the text to autocomplete and are not already in * the builtins or imported scripts. */ - m_currentScriptNodesCount = 0; nlr_buf_t nlr; if (nlr_push(&nlr) == 0) { @@ -575,7 +574,7 @@ void VariableBoxController::addNode(ScriptNode::Type type, NodeOrigin origin, co } // Shift all the following nodes - for (int i = *currentNodeCount; i >= insertionIndex; i--) { + for (int i = *currentNodeCount - 1; i >= insertionIndex; i--) { nodes[i+1] = nodes[i]; } // Add the node