GNOME Bugzilla – Bug 758698
Bug backward search + case insensitive + preceding multi-byte character
Last modified: 2015-11-30 18:56:43 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+.
It's a GTK+ bug, I've written a unit test. Now I'm trying to fix it.
(it's not a recent regression)
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.
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.
*** Bug 756794 has been marked as a duplicate of this bug. ***
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.
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 on attachment 316319 [details] [review] textiter: add more unit tests for search functions It was to show exactly what was the bug.
Review of attachment 316529 [details] [review]: thanks, looks good now
Attachment 316529 [details] pushed as 1a8f3e2 - textiter: fix bug in case insensitive backward search Thanks for the quick review.