Ticket #2396 (Find File "Whole words" search bug)
when searching in files for non english word with "Whole words" set "on" - then nothig will be found try search word: "время" and also "time" in next example: 'time' Время 'Time' 'время' Signed-off-by: Slava Zanko <slavazanko@gmail.com> Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
родитель
ca34026d46
Коммит
3934c6fb8e
@ -92,9 +92,12 @@ mc_search__cond_struct_new_init_normal (const char *charset, mc_search_t * lc_mc
|
|||||||
mc_search__normal_translate_to_regex (mc_search_cond->str->str, &mc_search_cond->len);
|
mc_search__normal_translate_to_regex (mc_search_cond->str->str, &mc_search_cond->len);
|
||||||
|
|
||||||
g_string_free (mc_search_cond->str, TRUE);
|
g_string_free (mc_search_cond->str, TRUE);
|
||||||
if (lc_mc_search->whole_words) {
|
if (lc_mc_search->whole_words)
|
||||||
g_string_prepend (tmp, "\\b");
|
{
|
||||||
g_string_append (tmp, "\\b");
|
/* 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}_]|$)");
|
||||||
}
|
}
|
||||||
mc_search_cond->str = tmp;
|
mc_search_cond->str = tmp;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ typedef enum
|
|||||||
/*** file scope functions ************************************************************************/
|
/*** file scope functions ************************************************************************/
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
mc_search__regex_str_append_if_special (GString * copy_to, GString * regex_str, gsize * offset)
|
mc_search__regex_str_append_if_special (GString * copy_to, const GString * regex_str, gsize * offset)
|
||||||
{
|
{
|
||||||
char *tmp_regex_str;
|
char *tmp_regex_str;
|
||||||
gsize spec_chr_len;
|
gsize spec_chr_len;
|
||||||
@ -622,10 +622,25 @@ mc_search__run_regex (mc_search_t * lc_mc_search, const void *user_data,
|
|||||||
{
|
{
|
||||||
case COND__FOUND_OK:
|
case COND__FOUND_OK:
|
||||||
#ifdef SEARCH_TYPE_GLIB
|
#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 */
|
#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];
|
start_pos = lc_mc_search->iovector[0];
|
||||||
end_pos = lc_mc_search->iovector[1];
|
end_pos = lc_mc_search->iovector[1];
|
||||||
|
}
|
||||||
#endif /* SEARCH_TYPE_GLIB */
|
#endif /* SEARCH_TYPE_GLIB */
|
||||||
if (found_len)
|
if (found_len)
|
||||||
*found_len = end_pos - start_pos;
|
*found_len = end_pos - start_pos;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user