diff options
-rw-r--r-- | generic/tkTextIndex.c | 19 | ||||
-rw-r--r-- | tests/textIndex.test | 10 |
2 files changed, 24 insertions, 5 deletions
diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index b2919d5..6a60faf 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -2218,7 +2218,7 @@ StartEnd( TkText *textPtr, /* Information about text widget. */ CONST char *string, /* String to parse for additional info about * modifier (count and units). Points to first - * character of modifer word. */ + * character of modifier word. */ TkTextIndex *indexPtr) /* Index to modify based on string. */ { CONST char *p; @@ -2369,11 +2369,20 @@ StartEnd( } firstChar = 0; } - offset -= chSize; - indexPtr->byteIndex -= chSize; + if (offset == 0) { + if (modifier == TKINDEX_DISPLAY) { + TkTextIndexBackChars(textPtr, indexPtr, 1, indexPtr, + COUNT_DISPLAY_INDICES); + } else { + TkTextIndexBackChars(NULL, indexPtr, 1, indexPtr, + COUNT_INDICES); + } + } else { + indexPtr->byteIndex -= chSize; + } + offset -= chSize; if (offset < 0) { - if (indexPtr->byteIndex < 0) { - indexPtr->byteIndex = 0; + if (indexPtr->byteIndex == 0) { goto done; } segPtr = TkTextIndexToSeg(indexPtr, &offset); diff --git a/tests/textIndex.test b/tests/textIndex.test index 92cbff0..abed3d4 100644 --- a/tests/textIndex.test +++ b/tests/textIndex.test @@ -905,6 +905,16 @@ test textIndex-22.12 {text index wordstart, unicode} { test textIndex-22.13 {text index wordstart, unicode} { text_test_word wordstart "\uc700\uc700 abc" 8 } 3 +test textIndex-22.14 {text index wordstart, unicode, start index at internal segment start} { + catch {destroy .t} + text .t + .t insert end "C'est du texte en fran\u00e7ais\n" + .t insert end "\u042D\u0442\u043E\u0020\u0442\u0435\u043A\u0441\u0442\u0020\u043D\u0430\u0020\u0440\u0443\u0441\u0441\u043A\u043E\u043C" + .t mark set insert 1.23 + set res [.t index "1.23 wordstart"] + .t mark set insert 2.16 + lappend res [.t index "2.16 wordstart"] [.t index "2.15 wordstart"] +} {1.18 2.13 2.13} test textIndex-22.15 {text index display wordstart} { catch {destroy .t} text .t |