summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/text.n3
-rw-r--r--generic/tkTextIndex.c6
-rw-r--r--tests/textIndex.test10
3 files changed, 15 insertions, 4 deletions
diff --git a/doc/text.n b/doc/text.n
index 7498cb5..f494414 100644
--- a/doc/text.n
+++ b/doc/text.n
@@ -229,7 +229,8 @@ Indicates the end of the text (the character just after the last newline).
.TP 12
\fImark\fR
.
-Indicates the character just after the mark whose name is \fImark\fR.
+Indicates the character just after the mark whose name is \fImark\fR (see
+\fBMARKS\fR for details).
.TP 12
\fItag\fB.first\fR
.
diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c
index 1a3cebd..31a95a7 100644
--- a/generic/tkTextIndex.c
+++ b/generic/tkTextIndex.c
@@ -2454,6 +2454,9 @@ StartEnd(
firstChar = 0;
}
if (offset == 0) {
+ if (indexPtr->byteIndex == 0) {
+ goto done;
+ }
if (modifier == TKINDEX_DISPLAY) {
TkTextIndexBackChars(textPtr, indexPtr, 1, indexPtr,
COUNT_DISPLAY_INDICES);
@@ -2466,9 +2469,6 @@ StartEnd(
}
offset -= chSize;
if (offset < 0) {
- if (indexPtr->byteIndex == 0) {
- goto done;
- }
segPtr = TkTextIndexToSeg(indexPtr, &offset);
}
}
diff --git a/tests/textIndex.test b/tests/textIndex.test
index 56154cf..b4e050f 100644
--- a/tests/textIndex.test
+++ b/tests/textIndex.test
@@ -941,6 +941,16 @@ test textIndex-22.15 {text index display wordstart} {
text .t
.t index "1.0 display wordstart" ; # used to crash
} 1.0
+test textIndex-22.16 {text index wordstart, bug [57b821d2db]} {
+ catch {destroy .t}
+ text .t
+ .t insert 1.0 " 123 5 789012 LINE-1\n\n 123 5 789000 LINE-3\n\n0123 5 789012 LINE-5"
+ set res [.t index "1.1 wordstart"]
+ lappend res [.t index "5.0 wordstart"]
+ .t mark set insert 1.1
+ lappend res [.t index "insert wordstart"]
+ lappend res [.t index "5.1 wordstart"]
+} {1.1 5.0 1.1 5.0}
test textIndex-23.1 {text paragraph start} {
pack [text .t2]