Monday, March 18, 2013

Multiple Line Undo Correction

The first problem identified while testing the many possible change scenarios was with an undo for a multiple line insert, where the last line is still marked as new (the cursor hasn't been moved away from the line yet when it would be reported as inserted).  The previously inserted lines removed by the undo were not reported as being deleted.

The problem occurred in the section that handles when lines are deleted and the cursor line was marked as new.  This was thought to only occur when the operation was either a backspace at the beginning of a new line or a delete at the end of a new line.  This situation was handled by resetting the modified line is new flag and not reporting an lines as being deleted.

However, the undo of a multiple line insert also causes this condition.  This was corrected decrementing the number of lines deleted instead of reporting no lines deleted.  For the case of a backspace or delete (and also an undo of a single line insert), the one line deleted becomes zero and no lines are reported as deleted.  For the undo of a multiple line insert, the correct number of lines are reported as deleted - one less for the new line that hasn't been inserted yet.

[commit faa2467463]