To: vim_dev@googlegroups.com Subject: Patch 8.0.1834 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1834 Problem: GUI: find/replace dialog does not handle some chars properly. Solution: Escape '?' when needed. Always escape backslash. (closes #2418, closes #2435) Files: src/gui.c *** ../vim-8.0.1833/src/gui.c 2018-05-05 21:00:56.800628452 +0200 --- src/gui.c 2018-05-13 17:03:53.778617209 +0200 *************** *** 5173,5180 **** #endif #if defined(FIND_REPLACE_DIALOG) || defined(PROTO) - static void concat_esc(garray_T *gap, char_u *text, int what); - /* * Get the text to use in a find/replace dialog. Uses the last search pattern * if the argument is empty. --- 5173,5178 ---- *************** *** 5239,5269 **** } /* - * Concatenate "text" to grow array "gap", escaping "what" with a backslash. - */ - static void - concat_esc(garray_T *gap, char_u *text, int what) - { - while (*text != NUL) - { - #ifdef FEAT_MBYTE - int l = (*mb_ptr2len)(text); - - if (l > 1) - { - while (--l >= 0) - ga_append(gap, *text++); - continue; - } - #endif - if (*text == what) - ga_append(gap, '\\'); - ga_append(gap, *text); - ++text; - } - } - - /* * Handle the press of a button in the find-replace dialog. * Return TRUE when something was added to the input buffer. */ --- 5237,5242 ---- *************** *** 5305,5314 **** ga_concat(&ga, (char_u *)"\\c"); if (flags & FRD_WHOLE_WORD) ga_concat(&ga, (char_u *)"\\<"); ! if (type == FRD_REPLACEALL || down) ! concat_esc(&ga, find_text, '/'); /* escape slashes */ ! else ! concat_esc(&ga, find_text, '?'); /* escape '?' */ if (flags & FRD_WHOLE_WORD) ga_concat(&ga, (char_u *)"\\>"); --- 5278,5288 ---- ga_concat(&ga, (char_u *)"\\c"); if (flags & FRD_WHOLE_WORD) ga_concat(&ga, (char_u *)"\\<"); ! /* escape / and \ */ ! p = vim_strsave_escaped(find_text, (char_u *)"/\\"); ! if (p != NULL) ! ga_concat(&ga, p); ! vim_free(p); if (flags & FRD_WHOLE_WORD) ga_concat(&ga, (char_u *)"\\>"); *************** *** 5371,5378 **** if (type == FRD_REPLACE) searchflags += SEARCH_START; i = msg_scroll; ! (void)do_search(NULL, down ? '/' : '?', ga.ga_data, 1L, ! searchflags, NULL, NULL); msg_scroll = i; /* don't let an error message set msg_scroll */ } --- 5345,5364 ---- if (type == FRD_REPLACE) searchflags += SEARCH_START; i = msg_scroll; ! if (down) ! { ! (void)do_search(NULL, '/', ga.ga_data, 1L, searchflags, NULL, NULL); ! } ! else ! { ! /* We need to escape '?' if and only if we are searching in the up ! * direction */ ! p = vim_strsave_escaped(ga.ga_data, (char_u *)"?"); ! if (p != NULL) ! (void)do_search(NULL, '?', p, 1L, searchflags, NULL, NULL); ! vim_free(p); ! } ! msg_scroll = i; /* don't let an error message set msg_scroll */ } *** ../vim-8.0.1833/src/version.c 2018-05-13 16:23:35.890011211 +0200 --- src/version.c 2018-05-13 17:05:10.986237585 +0200 *************** *** 763,764 **** --- 763,766 ---- { /* Add new patch number below this line */ + /**/ + 1834, /**/ -- Permission is granted to read this message out aloud on Kings Cross Road, London, under the condition that the orator is properly dressed. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///