Merge branch '3524_highlight_whole_word'

* 3524_highlight_whole_word:
  Ticket #3524: fix highliht of search result...
This commit is contained in:
Andrew Borodin 2015-09-19 18:28:34 +03:00
commit 221940fb36
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;