| Description: |
Index computation results in text widget depends on
the modifiers order.
This simple script reproduces the problem:
text .t
pack .t
.t insert 1.0 "this is a test text\n"
.t insert 2.0 "this is the second line\n"
.t insert 3.0 "this is the last line."
puts [.t compare "1.0 - 1l + 1l" == "1.0"]
puts [.t compare "1.0 + 1l - 1l" == "1.0"]
puts [.t compare "1.0 - 1c + 1c" == "1.0"]
puts [.t compare "1.0 + 1c - 1c" == "1.0"]
puts [.t compare "3.0 + 2l - 2l" == "3.0"]
puts [.t compare "3.0 - 2l + 2l" == "3.0"]
puts [.t compare "4.0 + 1c - 1c" == "4.0"]
puts [.t compare "4.0 - 1c + 1c" == "4.0"]
All the comparison results should be 1 since
(mathematically) there is no preferred order in
adding/substracting one line or character.
I believe Tcl analyzes the index string "base
modifier modifier..." by taking each modifier once at
a time, computes the new resulting index, and checks
for the text widget bounds at each iteration.
It should check for bounds only at the end of the
index computation.
The text widget man page tells that modifiers are
applied from left to right, that's OK, but it doesn't
tell that the boundaries are checked for each
intermediate result.
The boundaries should be checked only when all the
modifiers have been applied. If this is not possible,
at the very least the man page should warn that the
widget checks bounds after applying each modifier.
Occurs on Tcl/Tk 8.5 alpha and 8.4.11 as well.
|
| User Comments: |
vincentdarley added on 2005-11-16 16:54:09:
Logged In: YES
user_id=32170
The existing behaviour is correct, but I have now clarified
the documentation in both head and 8.4 branch.
I can understand why you might want some other behaviour,
but it's pretty hairy to specify a clear definition of that
other behaviour in all cases (how do you define a
non-existent displayline ? an non-existent elided
character? etc).
|