Description: |
Just been playing with ctext and I ran into a bug which causes an
endless loop on my system. The problem came from trying to
highlight Tcl comments, using:
ctext::addHighlightClassForRegexp $win comment navy
{#[^\n]*\n}
Then if I add the following to the text widget:
This is a test
# This is a test
foo
Then position the cursor somewhere in the comment, and press
backspace - endless loop occurs in ctext::highlight - the third while
1 loop. Problem seems to be that the [$win search..] stuff is
passed indices like 4.0 3.15 (i.e. start is after end), and it return
3.0 bizarrely (this may be a bug in the text widget, or possibly in
the Mac OS X implementation - I haven't followed up yet). The fix
was to add these lines after the {"" == $res} check:
# If result given is less than the start index (can happen), then
# break out
foreach {l1 c1} [split $res .] {l2 c2} [split $si .] { break }
if {$l1 < $l2 || ($l1 == $l2 && $c1 < $c2)} { break }
Everything seems to work again after adding that in. I would
upload a patch, but I'm very busy at present. Hassle me by email
if you really really want a patch!
|