From 8dfeaa1f6332f86ec3be268a2b310f936417c2ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Tue, 28 Nov 2017 11:06:56 +0100 Subject: [PATCH] [code] Fixed bug in Accordion. The last edited buffer was not properly computed. Change-Id: I7aadbc6e3ea41b3b0e344276933dca14c505ee71 --- apps/code/accordion.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/code/accordion.cpp b/apps/code/accordion.cpp index 3c8c7b108..9253cfebe 100644 --- a/apps/code/accordion.cpp +++ b/apps/code/accordion.cpp @@ -176,13 +176,16 @@ void Accordion::moveFreeSpaceAtPosition(int i) { assert(i >= 0 && i <= m_historySize); cleanFreeSpace(); int freeSpaceStart = startOfFreeSpace(); + int newFreeSpaceStart = freeSpaceStart; if (freeSpaceStart != i){ // First, move the chars that would be overriden by the free space. // The indexes depend on the relative positions of the free space and the // new destination. int sizeFreeSpace = freeSpaceSize(); - int len, src, dst, newFreeSpaceStart; + int len = 0; + int src = 0; + int dst = 0; if (freeSpaceStart > i) { len = freeSpaceStart - i; src = i; @@ -202,7 +205,7 @@ void Accordion::moveFreeSpaceAtPosition(int i) { } } - m_startOfLastEditedBuffer = i-1; + m_startOfLastEditedBuffer = newFreeSpaceStart-1; while (m_startOfLastEditedBuffer > 0 && m_history[m_startOfLastEditedBuffer-1] != 0 ) { m_startOfLastEditedBuffer--; }