GNOME Bugzilla – Bug 102862
Make scroll-to-iter magically work as expected
Last modified: 2014-08-22 12:04:06 UTC
Package: gtk+ Severity: minor Version: 2.2.0 Synopsis: 'scroll to lastest iter' does not work properly Bugzilla-Product: gtk+ Bugzilla-Component: GtkTextView Description: on change callback of text of buffer, get the latest iter and try to scroll to there; it fails. if showcase is mentioned, I'll put a thing. ------- Bug moved to this database by unknown@bugzilla.gnome.org 2003-01-08 12:36 ------- Reassigning to the default owner of the component, gtk-bugs@gtk.org.
Can you provide a small, self-contained testcase ?
Created attachment 14158 [details] gcc -o scroll_to_end scroll_to_end.c `pkg-config --libs --cflags gtk+-2.0`
This is a very, very, very, common GtkTextView FAQ The problem is that when you tell it to scroll to an iter right after you have inserted text, the size of the text has not yet been calculated... it is zero size. So, you need to use scroll-to-mark instead. I've argued in the past that we should make scroll-to-iter automatically do-the-right thing when called on a not-fully-valid textview ... create a temporary mark, scroll-to-mark that, and once things have settled down, destroy the mark.
closing out ancient bugs
In gedit there are some places where scroll_to_mark must be called in an idle. For example after loading a file. So it would be nice to make the API Just Work, either with scroll_to_iter or scroll_to_mark.