From 4610c49d14dca5fccf40ec756596ce6258821130 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 7 Apr 2015 20:12:59 +0000 Subject: Fix wordstart modifier for UTF-8 text - Bug [562118ce41] --- generic/tkTextIndex.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index 13f3957..7cb71bb 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -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); -- cgit v0.12 From d9cdbff3a06fecca2a07844fd0bd43fbfe6b85fb Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 7 Apr 2015 20:14:18 +0000 Subject: Fix typo in comment --- generic/tkTextIndex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index 7cb71bb..35ed143 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; -- cgit v0.12 From 092fc0d2df191c5676cd4c39da254d9a35e8da1e Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 8 Apr 2015 19:05:28 +0000 Subject: Added test for bug [562118ce41] --- tests/textIndex.test | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/textIndex.test b/tests/textIndex.test index 28dc0df..b9cc74d 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-23.1 {text paragraph start} { pack [text .t2] -- cgit v0.12