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 758698 - Bug backward search + case insensitive + preceding multi-byte character
Bug backward search + case insensitive + preceding multi-byte character
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
3.19.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2015-11-26 11:32 UTC by Sébastien Wilmet
Modified: 2015-11-30 18:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
textiter: add more unit tests for search functions (2.02 KB, patch)
2015-11-26 15:08 UTC, Sébastien Wilmet
reviewed Details | Review
textiter: fix bug in case insensitive backward search (3.13 KB, patch)
2015-11-26 15:08 UTC, Sébastien Wilmet
none Details | Review
textiter: fix bug in case insensitive backward search (4.15 KB, patch)
2015-11-30 15:40 UTC, Sébastien Wilmet
committed Details | Review

Description Sébastien Wilmet 2015-11-26 11:32:19 UTC
With the following content:

> é aa aa

Search "aa" with the default GtkSourceSearchSettings settings. The forward search works fine, but the backward search selects only the first 'a' of a search occurrence.

The bug doesn't occur with case sensitive search, and doesn't occur with regex search. So it occurs only with non-regex + case insensitive search. It's maybe a bug in GTK+.
Comment 1 Sébastien Wilmet 2015-11-26 13:59:54 UTC
It's a GTK+ bug, I've written a unit test. Now I'm trying to fix it.
Comment 2 Sébastien Wilmet 2015-11-26 14:00:26 UTC
(it's not a recent regression)
Comment 3 Sébastien Wilmet 2015-11-26 15:08:41 UTC
Created attachment 316319 [details] [review]
textiter: add more unit tests for search functions

See the FIXME comment, there is a bug with case insensitive backward
search with a preceding multi-byte character.
Comment 4 Sébastien Wilmet 2015-11-26 15:08:49 UTC
Created attachment 316320 [details] [review]
textiter: fix bug in case insensitive backward search

'win.lines' contains the same content as the GtkTextBuffer, so to find
@match_start, forward_chars_with_skipping() is called with
skip_decomp=FALSE (the last parameter). So far so good.

On the other hand, the content 'lines' (the needle split in lines) is
casefolded and normalized for a case insensitive search. So,
forward_chars_with_skipping(..., skip_decomp=TRUE) must be called only
for the portion of text containing the needle.

Since 'start_tmp' contains the location at the start of the match, we
can simply begin at that location to find the end of the match.
Comment 5 Tim-Philipp Müller 2015-11-27 11:26:46 UTC
*** Bug 756794 has been marked as a duplicate of this bug. ***
Comment 6 Matthias Clasen 2015-11-30 12:50:34 UTC
Review of attachment 316319 [details] [review]:

I don't really like committing commented out tests like that. I would suggest to simply commit the test(s) together with the fix, or afterwards.
Comment 7 Sébastien Wilmet 2015-11-30 15:40:14 UTC
Created attachment 316529 [details] [review]
textiter: fix bug in case insensitive backward search

'win.lines' contains the same content as the GtkTextBuffer, so to find
@match_start, forward_chars_with_skipping() is called with
skip_decomp=FALSE (the last parameter). So far so good.

On the other hand, the content 'lines' (the needle split in lines) is
casefolded and normalized for a case insensitive search. So,
forward_chars_with_skipping(..., skip_decomp=TRUE) must be called only
for the portion of text containing the needle.

Since 'start_tmp' contains the location at the start of the match, we
can simply begin at that location to find the end of the match.

Unit tests are added.
Comment 8 Sébastien Wilmet 2015-11-30 15:43:50 UTC
Comment on attachment 316319 [details] [review]
textiter: add more unit tests for search functions

It was to show exactly what was the bug.
Comment 9 Matthias Clasen 2015-11-30 15:59:13 UTC
Review of attachment 316529 [details] [review]:

thanks, looks good now
Comment 10 Sébastien Wilmet 2015-11-30 18:56:36 UTC
Attachment 316529 [details] pushed as 1a8f3e2 - textiter: fix bug in case insensitive backward search

Thanks for the quick review.