summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogelnew1@free.fr <fvogel>2016-03-27 15:02:41 (GMT)
committerfvogelnew1@free.fr <fvogel>2016-03-27 15:02:41 (GMT)
commit6105a94b315f3b8a2378fcb39818881190ea5ca6 (patch)
tree7d706f6c1eeada6dca99711a031e0d88e9d2dcf6
parentdbb8d064ae1be5397854f89b0e03e4d84f515a29 (diff)
parentc70100811aa8e479e3dad6043e472ce829732b16 (diff)
downloadtk-6105a94b315f3b8a2378fcb39818881190ea5ca6.zip
tk-6105a94b315f3b8a2378fcb39818881190ea5ca6.tar.gz
tk-6105a94b315f3b8a2378fcb39818881190ea5ca6.tar.bz2
End of fix for [18c08df753] - Merged branch bug-2886436fff-option2
-rw-r--r--doc/text.n8
-rw-r--r--generic/tkText.c15
2 files changed, 15 insertions, 8 deletions
diff --git a/doc/text.n b/doc/text.n
index d2f0c82..32019ce 100644
--- a/doc/text.n
+++ b/doc/text.n
@@ -1216,8 +1216,12 @@ If \fIindex2\fR does not specify a position later in the text
than \fIindex1\fR then no characters are deleted.
If \fIindex2\fR is not specified then the single character at
\fIindex1\fR is deleted.
-It is not allowable to delete characters in a way that would leave
-the text without a newline as the last character.
+Attempts to delete characters in a way that would leave
+the text without a newline as the last character will be tweaked by the
+text widget to avoid this. In particular, deletion of complete lines of
+text up to the end of the text will also delete the newline character just
+before the deleted block so that it is replaced by the new final newline
+of the text widget.
The command returns an empty string.
If more indices are given, multiple ranges of text will be deleted.
All indices are first checked for validity before any deletions are made.
diff --git a/generic/tkText.c b/generic/tkText.c
index 4942913..8edf82d 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -3004,12 +3004,15 @@ DeleteIndexRange(
* dummy empty line at the end of the text. If the final newline of the
* file (just before the dummy line) is being deleted, then back up index
* to just before the newline. If there is a newline just before the first
- * character being deleted, then back up the first index too, so that an
- * even number of lines gets deleted. Furthermore, remove any tags that
- * are present on the newline that isn't going to be deleted after all
- * (this simulates deleting the newline and then adding a "clean" one back
- * again). Note that index1 and index2 might now be equal again which
- * means that no text will be deleted but tags might be removed.
+ * character being deleted, then back up the first index too. The idea is
+ * that a deletion involving a range starting at a line start and
+ * including the final \n (i.e. index2 is "end") is an attempt to delete
+ * complete lines, so the \n before the deleted block shall become the new
+ * final \n. Furthermore, remove any tags that are present on the newline
+ * that isn't going to be deleted after all (this simulates deleting the
+ * newline and then adding a "clean" one back again). Note that index1 and
+ * index2 might now be equal again which means that no text will be
+ * deleted but tags might be removed.
*/
line1 = TkBTreeLinesTo(textPtr, index1.linePtr);