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