summaryrefslogtreecommitdiffstats
path: root/generic/tkText.c
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2016-03-27 15:25:22 (GMT)
committerfvogel <fvogelnew1@free.fr>2016-03-27 15:25:22 (GMT)
commit32ed623c6a6ea47b434caae5452486b9ed93e197 (patch)
tree0dd6bfd881f87860ca526ac23cda6653a861d285 /generic/tkText.c
parentb8683c2dcc13728de8db64f269aaa5c68abe514f (diff)
parent3b50c2352b6b0e6c46ba384ec7795ecedafd09e4 (diff)
downloadtk-32ed623c6a6ea47b434caae5452486b9ed93e197.zip
tk-32ed623c6a6ea47b434caae5452486b9ed93e197.tar.gz
tk-32ed623c6a6ea47b434caae5452486b9ed93e197.tar.bz2
Fixed [18c08df753] - Change of behaviour for text widget last newline
Diffstat (limited to 'generic/tkText.c')
-rw-r--r--generic/tkText.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/generic/tkText.c b/generic/tkText.c
index 88fe19a..506075d 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -3089,11 +3089,16 @@ DeleteIndexRange(
* The code below is ugly, but it's needed to make sure there is always a
* 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. 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.
+ * to just before the newline. If there is a newline just before the first
+ * 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);
@@ -3106,6 +3111,10 @@ DeleteIndexRange(
oldIndex2 = index2;
TkTextIndexBackChars(NULL, &oldIndex2, 1, &index2, COUNT_INDICES);
line2--;
+ if ((index1.byteIndex == 0) && (line1 != 0)) {
+ TkTextIndexBackChars(NULL, &index1, 1, &index1, COUNT_INDICES);
+ line1--;
+ }
arrayPtr = TkBTreeGetTags(&index2, NULL, &arraySize);
if (arrayPtr != NULL) {
for (i = 0; i < arraySize; i++) {