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 618852 - gtk_text_iter_forward_visible_cursor_position does not move to end of buffer/view
gtk_text_iter_forward_visible_cursor_position does not move to end of buffer/...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2010-05-17 09:17 UTC by jessevdk@gmail.com
Modified: 2014-07-17 11:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
tests textiter: unit tests for cursor positions (4.59 KB, patch)
2014-04-28 11:33 UTC, Sébastien Wilmet
committed Details | Review
tests textiter: unit tests for visible word boundaries (4.67 KB, patch)
2014-07-15 15:20 UTC, Sébastien Wilmet
accepted-commit_now Details | Review
tests textiter: unit tests for sentence boundaries (4.12 KB, patch)
2014-07-15 15:20 UTC, Sébastien Wilmet
accepted-commit_now Details | Review
textiter: fix bug in find_by_log_attrs() (4.96 KB, patch)
2014-07-15 15:20 UTC, Sébastien Wilmet
accepted-commit_now Details | Review
textiter: simplify FindLogAttrFunc (8.35 KB, patch)
2014-07-15 15:20 UTC, Sébastien Wilmet
accepted-commit_now Details | Review
textiter: make the FindLogAttrFunc functions clearer (3.69 KB, patch)
2014-07-15 15:20 UTC, Sébastien Wilmet
accepted-commit_now Details | Review
textiter: fix bug in FindLogAttrFunc functions (3.20 KB, patch)
2014-07-15 15:20 UTC, Sébastien Wilmet
accepted-commit_now Details | Review
textiter: fix bug in find_visible_by_log_attrs() (2.49 KB, patch)
2014-07-15 17:14 UTC, Sébastien Wilmet
accepted-commit_now Details | Review

Description jessevdk@gmail.com 2010-05-17 09:17:24 UTC
gtk_text_iter_forward_visible_cursor_position does not move to the last possible cursor position (i.e. the end position), but instead stops before the last character in the buffer.
Comment 1 Sébastien Wilmet 2014-04-28 11:33:54 UTC
Created attachment 275320 [details] [review]
tests textiter: unit tests for cursor positions

See the FIXME comment.
Comment 2 Sébastien Wilmet 2014-04-28 11:36:21 UTC
For the fix of this bug I'm waiting for the patches at bug #629129 since they touch the same code.
Comment 3 Paolo Borelli 2014-07-13 14:57:33 UTC
Review of attachment 275320 [details] [review]:

The unit test looks correct to me. Looking forward the patch to actually fix the bug :)
Comment 4 Sébastien Wilmet 2014-07-13 15:13:41 UTC
Comment on attachment 275320 [details] [review]
tests textiter: unit tests for cursor positions

Pushed to the master branch, thanks for the review.
Comment 5 Sébastien Wilmet 2014-07-15 15:20:14 UTC
Created attachment 280725 [details] [review]
tests textiter: unit tests for visible word boundaries

As the FIXME comments show, there are several problems.
Comment 6 Sébastien Wilmet 2014-07-15 15:20:20 UTC
Created attachment 280726 [details] [review]
tests textiter: unit tests for sentence boundaries

As the FIXME comment shows, there is a bug. It is the same bug as for
the word boundaries.
Comment 7 Sébastien Wilmet 2014-07-15 15:20:25 UTC
Created attachment 280727 [details] [review]
textiter: fix bug in find_by_log_attrs()

Do not work with the iter passed as the function argument. Work with
another iter, and set it back to the function argument only if something
has been found.

This fixes a few unit tests. But there are regressions for a few others.
Comment 8 Sébastien Wilmet 2014-07-15 15:20:31 UTC
Created attachment 280728 [details] [review]
textiter: simplify FindLogAttrFunc

The min_offset parameter was always 0. Since there are some bugs in this
code, it'll be clearer if there are fewer parameters.
Comment 9 Sébastien Wilmet 2014-07-15 15:20:36 UTC
Created attachment 280729 [details] [review]
textiter: make the FindLogAttrFunc functions clearer

- Return true (found) and false (not found) explicitly.
- Set found_offset only when something has been found.

find_backward_cursor_pos_func() was a bit different, the while loop had
the condition "offset > 0" but the return was "offset >= 0". Probably a
micro-optimization, since offset == 0 is always a cursor position.
Anyway now the code is the same as the other functions.
Comment 10 Sébastien Wilmet 2014-07-15 15:20:41 UTC
Created attachment 280730 [details] [review]
textiter: fix bug in FindLogAttrFunc functions

attrs[len] is the last PangoLogAttr available, at the iter position after the
last character of the line.

For a line in the middle or the start of the buffer, the '\n' is taken
into account by 'len'. For example the is_word_end is generally reached
before the '\n', not after. But for the last line in the buffer, where
there is no trailing '\n', it is important to test until attrs[len].

The bug didn't occur before because find_by_log_attrs() worked directly
on the iter passed as the function argument. But now it is no longer the
case.
Comment 11 Sébastien Wilmet 2014-07-15 17:14:39 UTC
Created attachment 280746 [details] [review]
textiter: fix bug in find_visible_by_log_attrs()

find_by_log_attrs() can return true only in this case:
return moved && !gtk_text_iter_is_end (arg_iter);

So if the iter moved (i.e. something has been found), but is the end
iter, find_by_log_attrs() returns false.

Now the same checks are made in find_visible_by_log_attrs(). The public
functions using find_visible_by_log_attrs() say in their documentation
that false is returned for the end iter, hence the check with
gtk_text_iter_is_end().
Comment 12 Sébastien Wilmet 2014-07-15 17:16:02 UTC
With the last patch this bug is finally fixed.
Comment 13 Matthias Clasen 2014-07-17 03:44:21 UTC
Review of attachment 280725 [details] [review]:

sure
Comment 14 Matthias Clasen 2014-07-17 03:44:36 UTC
Review of attachment 280725 [details] [review]:

sure
Comment 15 Matthias Clasen 2014-07-17 03:44:52 UTC
Review of attachment 280726 [details] [review]:

ok
Comment 16 Matthias Clasen 2014-07-17 03:45:34 UTC
Review of attachment 280727 [details] [review]:

ok
Comment 17 Matthias Clasen 2014-07-17 03:47:18 UTC
Review of attachment 280728 [details] [review]:

ok
Comment 18 Matthias Clasen 2014-07-17 03:48:00 UTC
Review of attachment 280729 [details] [review]:

ok
Comment 19 Matthias Clasen 2014-07-17 03:48:53 UTC
Review of attachment 280730 [details] [review]:

ok
Comment 20 Matthias Clasen 2014-07-17 03:49:11 UTC
Review of attachment 280746 [details] [review]:

ok
Comment 21 Sébastien Wilmet 2014-07-17 11:01:24 UTC
Thanks for the review, all the commits are pushed to the master branch.