Ticket #3524: fix highliht of search result...

...in case of "Regular expression" and "Whole words".

The bug:
If there's no match, it's properly reported so.
If there's a match, however, the mcview's viewport is properly scrolled
vertically, but the search result is not highlighted. Plus, you can
press "Search again" once (or more times if there are multiple matches
in the line) and it won't progress to the next match.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Egmont Koblinger 2015-09-19 18:24:07 +03:00 committed by Andrew Borodin
parent b8ffa1b966
commit a0741b0a08
2 changed files with 7 additions and 17 deletions

View File

@ -94,9 +94,10 @@ mc_search__cond_struct_new_init_normal (const char *charset, mc_search_t * lc_mc
if (lc_mc_search->whole_words)
{
/* NOTE: \b as word boundary doesn't allow search
* whole words with non-ASCII symbols */
g_string_prepend (tmp, "(^|[^\\p{L}\\p{N}_])(");
g_string_append (tmp, ")([^\\p{L}\\p{N}_]|$)");
* whole words with non-ASCII symbols.
* Update: Is it still true nowadays? Probably not. #2396, #3524 */
g_string_prepend (tmp, "(?<![\\p{L}\\p{N}_])");
g_string_append (tmp, "(?![\\p{L}\\p{N}_])");
}
mc_search_cond->str = tmp;

View File

@ -881,21 +881,10 @@ mc_search__run_regex (mc_search_t * lc_mc_search, const void *user_data,
{
case COND__FOUND_OK:
#ifdef SEARCH_TYPE_GLIB
if (lc_mc_search->whole_words)
g_match_info_fetch_pos (lc_mc_search->regex_match_info, 2, &start_pos, &end_pos);
else
g_match_info_fetch_pos (lc_mc_search->regex_match_info, 0, &start_pos, &end_pos);
g_match_info_fetch_pos (lc_mc_search->regex_match_info, 0, &start_pos, &end_pos);
#else /* SEARCH_TYPE_GLIB */
if (lc_mc_search->whole_words)
{
start_pos = lc_mc_search->iovector[4];
end_pos = lc_mc_search->iovector[5];
}
else
{
start_pos = lc_mc_search->iovector[0];
end_pos = lc_mc_search->iovector[1];
}
start_pos = lc_mc_search->iovector[0];
end_pos = lc_mc_search->iovector[1];
#endif /* SEARCH_TYPE_GLIB */
if (found_len != NULL)
*found_len = end_pos - start_pos;