[code] Fixed bug in Accordion.

The last edited buffer was not properly computed.

Change-Id: I7aadbc6e3ea41b3b0e344276933dca14c505ee71
This commit is contained in:
Léa Saviot
2017-11-28 11:06:56 +01:00
parent 9d57d7f173
commit 8dfeaa1f63

View File

@@ -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--;
}