After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 156164 - Fix _gtk_text_buffer_get_line_log_attrs for last line
Fix _gtk_text_buffer_get_line_log_attrs for last line
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
3.10.x
Other Linux
: Normal normal
: Small fix
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2004-10-22 17:22 UTC by Owen Taylor
Modified: 2014-08-21 16:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
textbuffer: unit tests for the empty last line (5.09 KB, patch)
2014-08-20 17:23 UTC, Sébastien Wilmet
committed Details | Review
Simplify _gtk_text_buffer_get_line_log_attrs() (5.42 KB, patch)
2014-08-20 17:23 UTC, Sébastien Wilmet
committed Details | Review

Description Owen Taylor 2004-10-22 17:22:32 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.
Comment 1 Timothy Arceri 2013-10-01 22:13:10 UTC
Just updating to reflect that this is still a problem in the current version of GTK.
Comment 2 Sébastien Wilmet 2014-08-20 17:23:03 UTC
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.
Comment 3 Sébastien Wilmet 2014-08-20 17:23:09 UTC
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().
Comment 4 Matthias Clasen 2014-08-21 16:30:39 UTC
Review of attachment 283984 [details] [review]:

looks good
Comment 5 Matthias Clasen 2014-08-21 16:31:00 UTC
Review of attachment 283985 [details] [review]:

ok
Comment 6 Sébastien Wilmet 2014-08-21 16:50:59 UTC
Thank you for the review, the commits are pushed to the master branch.