|
2026-10-26
| ||
| 14:04 | • Closed ticket [3e7c4a039d]: tcl_startOfPreviousWord ignores the last character w... artifact: c4c8b218e3 user: jan.nijtmans | |
| 14:01 | Fix [3e7c4a039d]: tcl_startOfPreviousWord ignores the last character when start is the string length check-in: 31222d571c user: jan.nijtmans tags: core-8-6-branch | |
| 13:08 | Fix [3e7c4a039d]: tcl_startOfPreviousWord ignores the last character when start is the string length check-in: 840edb7f12 user: jan.nijtmans tags: core-9-0-branch | |
| 12:02 | Fix [3e7c4a039d]: tcl_startOfPreviousWord ignores the last character when start is the string length check-in: c79e0372a7 user: jan.nijtmans tags: trunk, main | |
|
2026-10-25
| ||
| 12:03 | • Ticket [3e7c4a039d] tcl_startOfPreviousWord ignores the last character when star... artifact: 0b307ec870 user: serhiy.storchaka | |
| 12:03 | Fix [3e7c4a039d]: tcl_startOfPreviousWord ignores the last character when start is the string length... closed check-in: 5e430a21cd user: serhiy.storchaka tags: word-previous-last-char | |
| 11:56 | • New ticket [3e7c4a039d] tcl_startOfPreviousWord ignores the last character when ... artifact: 4988a3b3af user: serhiy.storchaka | |
tcl_startOfPreviousWord ignores the last character when start is the string length
% tcl_startOfPreviousWord {a b c} 5
2
% tcl_startOfPreviousWord {ab c} 4
0
The expected results are 4 and 3, which 8.5 and 8.6.13 return. The last character is dropped, so the last word is not found when it has one character. For longer words the result happens to be right (word-2.6).
This is a regression from the fix for [16e25e1402] ([8f65470f72], 8.6.14): [string range [string range $str 0 $start] 0 end-1] drops the last character also when $start is beyond the end of the string, while the old [string range $str 0 $start-1] did not.
It affects Tk: in an entry or spinbox using these procedures (8.6, or -locale tcl8 in 9.x), Ctrl+Left from the end of the text skips a final one-character word.
A possible fix that keeps end-1 working:
set prefix [string range $str 0 $start]
if {[string index $str $start] ne ""} {
set prefix [string range $prefix 0 end-1]
}
regexp -indices -- $WordBreakRE(previous) $prefix result word
with tests such as tcl_startOfPreviousWord "ab c" 4 → 3 and tcl_startOfPreviousWord "ab c" end+1 → 3. With it, all word-2.* cases still give the same results (checked with 8.6.18 and 9.1.1 by redefining the procedure).
31222d571cFix [3e7c4a039d]: tcl_startOfPreviousWord ignores the last character when start is the string length check-in2026-10-26 14:01:47840edb7f12Fix [3e7c4a039d]: tcl_startOfPreviousWord ignores the last character when start is the string length check-in2026-10-26 13:08:21c79e0372a7Fix [3e7c4a039d]: tcl_startOfPreviousWord ignores the last character when start is the string length check-in2026-10-26 12:02:285e430a21cdFix [3e7c4a039d]: tcl_startOfPreviousWord ignores the last character when start is the string length. Drop the character at $start only if there is one (regression from [16e25e1402] in 8.6.14). check-in2026-10-25 12:03:35
Proposed fix in branch word-previous-last-char (the change suggested above), with tests word-2.10..2.14.
Fix merged to [trunk], core-9-0-branch and core-8-6-branch
Many thanks!