Wednesday, March 6, 2013

Issues With Newly Inserted Lines

The edit box contains a variable to indicate when a line has been inserted but not yet reported as being inserted (in other words, a new line).  Lines are not reported as being modified (changed) until the cursor leaves the line.  This will prevent unnecessary compiling of the line as it is being entered.  This includes a new line that is being entered.  There were some issues with new lines that were corrected.

A new line can only occur when multiple lines have changed or a single line has changed and the change is not at the beginning of a line.  After a change, the modified line is marked as new if there was a single line change and the change was not at the beginning of a line or if the cursor is at the end of a line.  The problem was with this last part when the change was due to a delete at the end of a line and the next line was blank (the cursor was still at the end of the line).  This was corrected by checking if characters were added by the change.

When on a new line, if a backspace occurs is entered the beginning of the line or a delete at the end of the line, the current line or the next line was being reported as deleted, but a new line wasn't reported as inserted yet.  This was corrected by adding a check if the current line is modified and new, to reset the status of the line to just modified, and to not report the line that is removed as deleted.  This change caused another minor problem where an empty lines changed signal was emitted (no changed, deleted or inserted lines), so this empty signal was prevented.

The variable being used to indicate whether a modified line was changed or inserted (new) was an enumeration, however, this enumeration only had two values.  To make the code easier to read, the variable was renamed and changed to a boolean variable.

Finally, deleted lines were not always reported correctly in the main window's program changed slot that is temporarily connected to the lines changed signal for debugging.  The deleted lines loop was corrected so that these lines are reported correctly.

[commit f10eca50ba] [commit 4364d7447f] [commit 74a5eb93a0] [commit 53bf17fda2]