diff --git a/src/viewer/search.c b/src/viewer/search.c index 665f03750..bf60b3fb0 100644 --- a/src/viewer/search.c +++ b/src/viewer/search.c @@ -53,7 +53,7 @@ /*** file scope variables ************************************************************************/ -static int search_cb_char_curr_index = 0; +static int search_cb_char_curr_index = -1; static char search_cb_char_buffer[6]; /*** file scope functions ************************************************************************/ @@ -81,6 +81,7 @@ mcview_find (mcview_t * view, gsize search_start, gsize * len) gsize search_end; view->search_numNeedSkipChar = 0; + search_cb_char_curr_index = -1; if (mcview_search_options.backwards) { @@ -171,6 +172,15 @@ mcview_search_cmd_callback (const void *user_data, gsize char_offset) return MC_SEARCH_CB_SKIP; } + if (search_cb_char_curr_index == -1) + { + search_cb_char_curr_index = 0; + if (view->search_nroff_seq->char_width > 1) + g_unichar_to_utf8 (view->search_nroff_seq->current_char, search_cb_char_buffer); + else + search_cb_char_buffer[0] = (char) view->search_nroff_seq->current_char; + } + if (search_cb_char_curr_index < view->search_nroff_seq->char_width) { lc_byte = search_cb_char_buffer[search_cb_char_curr_index];