[text see] adjusts the text widget to the wrong place when called immediately after a text widget is created and programmatically populated. (Subsequent calls to [text see] produce the correct behavior--even if they immediately follow the faulty call.)
# test script 1
# demonstrates [text see] bug
package require Tcl 8.5
package require Tk 8.5
set t [text .t -wrap none]
set s [scrollbar .s -command [list $t yview]]
$t configure -yscrollcommand [list $s set]
grid $t $s -sticky nsew
for {set i 1} {$i <= 100} {incr i} {
$t insert end "This is line $i\n"
}
$t see 1.0
raise .
generates window captures of bug (100 iterations); creates window to browse through captures
Logged In: YES
user_id=1388916
Originator: NO
I do not think this is really a bug.
You have to do 'update idletasks' after gridding the text widget. Otherwise the see operation doesn't know the size of the widget yet. In fact, [winfo height .t] == 1 then, and the see operation puts the bottom pixel line of the top text line at the top.
Logged In: YES
user_id=1326110
Originator: YES
I can understand that the widget doesn't have all the information it needs before [update idletasks]. But the choice of which pixel to put at the top of the screen in this situation seems arbitrary--my limited tests show that it's not always the bottom pixel, but never the top pixel, which would seem to be the logical choice. The end result seems wrong.
Tk 8.4 deals with the same [update] limitation, but produces a satisfactory result in spite of this by positioning the top pixel of the requested line at the top of the widget. Shouldn't 8.5 do the same thing? (I realize the 8.4 text widget has no choice but to work with the top pixel, whereas the 8.5 text widget does have such a choice, but still...)