GNOME Bugzilla – Bug 156164
Fix _gtk_text_buffer_get_line_log_attrs for last line
Last modified: 2014-08-21 16:50:59 UTC
_gtk_text_buffer_get_line_log_attrs() properly returns a length-1-array for any empty line, *except* for the empty last line of the buffer, for which it returns All the callers of _gtk_text_buffer_get_line_log_attrs() currently special case this, which is ridiculous. The function needs to be fixed.
Just updating to reflect that this is still a problem in the current version of GTK.
Created attachment 283984 [details] [review] textbuffer: unit tests for the empty last line For functions using _gtk_text_buffer_get_line_log_attrs(): - gtk_text_buffer_backspace() - some gtk_text_iter functions (word/sentence/cursor boundaries) As the FIXME comments show, there is a bug with gtk_text_iter_is_cursor_position() for an empty last line.
Created attachment 283985 [details] [review] Simplify _gtk_text_buffer_get_line_log_attrs() NULL was returned in case of an empty last line. Every users needed to special-case this. Now it will return the expected result: char_len of 0 with one PangoLogAttr. In compute_log_attrs(), 'paragraph' will be the empty string "" with 'char_len' == 0. pango_get_log_attrs() works fine with an empty string, it will return one correct PangoLogAttr (because there is one text position for the empty string). It fixes the unit tests for gtk_text_iter_is_cursor_position().
Review of attachment 283984 [details] [review]: looks good
Review of attachment 283985 [details] [review]: ok
Thank you for the review, the commits are pushed to the master branch.