While testing the changes for detecting changed lines when a pasting text over a selection, some problems were found with the proper reporting of lines that were deleted. The problem was in the existing capture deleted lines routine, not in the new changes.
This routine was simply reporting lines being deleted from the line of the selection start position, for the number of lines in the selection minus one (the remaining line was set as modified). This did not take into account if the selection start or end position was at the begin or end of their respective lines. There are situations where the first line of the selection should not be reported as deleted (for instance, if the selection start is not at the beginning of the line, then the line will not be deleted, only modified).
Two checks needed to be made - the first line reported as deleted, and if the line the cursor is on after the deletion will be modified by the delete operation. For instance, if the selection starts at the end of the line, and the selection end is on a blank line, then the final cursor line after the deletion will not have been modified.
The first line to report as deleted will be the line the selection start position is at unless the selection start position is not at the begin of the line or at the end of the line and the selection end position is not at the begin of the line, in which case, the first line to report is the next line after the start position line.
The delete operation will cause the line the cursor is at afterward to be marked as modified via the document changed signal. The modified line variable needs to be reset if the line is not actually modified by the delete operation. This condition is if the selection start and end positions are at the begin of their lines, or if both are at the end of their lines.
As before, if the selection start and end are on the same line, no lines are reported as being deleted. The Selection class was modified to also be able to report if the selection start and end positions are at the begin or end of their lines.
[commit c753fd1662]
Saturday, February 16, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)