comparison src/ex_docmd.c @ 14760:fd69edd2c67e v8.1.0392

patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled commit https://github.com/vim/vim/commit/50eb16c3b23235b21ce4494673a7741a9a196176 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 15 15:42:40 2018 +0200 patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled Problem: Error while typing :/foo/s// with 'incsearch' enabled. Solution: Do not give search errors when highlighting matches.
author Christian Brabandt <cb@256bit.org>
date Sat, 15 Sep 2018 15:45:10 +0200
parents 0a3b9ecf7cb8
children ac5d0d27aef9
comparison
equal deleted inserted replaced
14759:f11109e68c68 14760:fd69edd2c67e
115 #if !defined(FEAT_QUICKFIX) || !defined(FEAT_EVAL) 115 #if !defined(FEAT_QUICKFIX) || !defined(FEAT_EVAL)
116 # define ex_cexpr ex_ni 116 # define ex_cexpr ex_ni
117 #endif 117 #endif
118 118
119 static int check_more(int, int); 119 static int check_more(int, int);
120 static linenr_T get_address(exarg_T *, char_u **, int addr_type, int skip, int to_other_file, int address_count); 120 static linenr_T get_address(exarg_T *, char_u **, int addr_type, int skip, int silent, int to_other_file, int address_count);
121 static void get_flags(exarg_T *eap); 121 static void get_flags(exarg_T *eap);
122 #if !defined(FEAT_PERL) \ 122 #if !defined(FEAT_PERL) \
123 || !defined(FEAT_PYTHON) || !defined(FEAT_PYTHON3) \ 123 || !defined(FEAT_PYTHON) || !defined(FEAT_PYTHON3) \
124 || !defined(FEAT_TCL) \ 124 || !defined(FEAT_TCL) \
125 || !defined(FEAT_RUBY) \ 125 || !defined(FEAT_RUBY) \
1851 if (ea.cmdidx == CMD_wincmd && p != NULL) 1851 if (ea.cmdidx == CMD_wincmd && p != NULL)
1852 get_wincmd_addr_type(skipwhite(p), &ea); 1852 get_wincmd_addr_type(skipwhite(p), &ea);
1853 } 1853 }
1854 1854
1855 ea.cmd = cmd; 1855 ea.cmd = cmd;
1856 if (parse_cmd_address(&ea, &errormsg) == FAIL) 1856 if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL)
1857 goto doend; 1857 goto doend;
1858 1858
1859 /* 1859 /*
1860 * 5. Parse the command. 1860 * 5. Parse the command.
1861 */ 1861 */
2834 continue; 2834 continue;
2835 2835
2836 case 't': if (checkforcmd(&p, "tab", 3)) 2836 case 't': if (checkforcmd(&p, "tab", 3))
2837 { 2837 {
2838 long tabnr = get_address(eap, &eap->cmd, ADDR_TABS, 2838 long tabnr = get_address(eap, &eap->cmd, ADDR_TABS,
2839 eap->skip, FALSE, 1); 2839 eap->skip, skip_only, FALSE, 1);
2840 if (tabnr == MAXLNUM) 2840 if (tabnr == MAXLNUM)
2841 cmdmod.tab = tabpage_index(curtab) + 1; 2841 cmdmod.tab = tabpage_index(curtab) + 1;
2842 else 2842 else
2843 { 2843 {
2844 if (tabnr < 0 || tabnr > LAST_TAB_NR) 2844 if (tabnr < 0 || tabnr > LAST_TAB_NR)
2909 vim_regfree(cmdmod.filter_regmatch.regprog); 2909 vim_regfree(cmdmod.filter_regmatch.regprog);
2910 } 2910 }
2911 2911
2912 /* 2912 /*
2913 * Parse the address range, if any, in "eap". 2913 * Parse the address range, if any, in "eap".
2914 * May set the last search pattern. 2914 * May set the last search pattern, unless "silent" is TRUE.
2915 * Return FAIL and set "errormsg" or return OK. 2915 * Return FAIL and set "errormsg" or return OK.
2916 */ 2916 */
2917 int 2917 int
2918 parse_cmd_address(exarg_T *eap, char_u **errormsg) 2918 parse_cmd_address(exarg_T *eap, char_u **errormsg, int silent)
2919 { 2919 {
2920 int address_count = 1; 2920 int address_count = 1;
2921 linenr_T lnum; 2921 linenr_T lnum;
2922 2922
2923 // Repeat for all ',' or ';' separated addresses. 2923 // Repeat for all ',' or ';' separated addresses.
2953 eap->line2 = qf_get_cur_valid_idx(eap); 2953 eap->line2 = qf_get_cur_valid_idx(eap);
2954 break; 2954 break;
2955 #endif 2955 #endif
2956 } 2956 }
2957 eap->cmd = skipwhite(eap->cmd); 2957 eap->cmd = skipwhite(eap->cmd);
2958 lnum = get_address(eap, &eap->cmd, eap->addr_type, eap->skip, 2958 lnum = get_address(eap, &eap->cmd, eap->addr_type, eap->skip, silent,
2959 eap->addr_count == 0, address_count++); 2959 eap->addr_count == 0, address_count++);
2960 if (eap->cmd == NULL) // error detected 2960 if (eap->cmd == NULL) // error detected
2961 return FAIL; 2961 return FAIL;
2962 if (lnum == MAXLNUM) 2962 if (lnum == MAXLNUM)
2963 { 2963 {
4448 */ 4448 */
4449 static linenr_T 4449 static linenr_T
4450 get_address( 4450 get_address(
4451 exarg_T *eap UNUSED, 4451 exarg_T *eap UNUSED,
4452 char_u **ptr, 4452 char_u **ptr,
4453 int addr_type, /* flag: one of ADDR_LINES, ... */ 4453 int addr_type, // flag: one of ADDR_LINES, ...
4454 int skip, /* only skip the address, don't use it */ 4454 int skip, // only skip the address, don't use it
4455 int to_other_file, /* flag: may jump to other file */ 4455 int silent, // no errors or side effects
4456 int address_count UNUSED) /* 1 for first address, >1 after comma */ 4456 int to_other_file, // flag: may jump to other file
4457 int address_count UNUSED) // 1 for first address, >1 after comma
4457 { 4458 {
4458 int c; 4459 int c;
4459 int i; 4460 int i;
4460 long n; 4461 long n;
4461 char_u *cmd; 4462 char_u *cmd;
4597 if (*cmd == c) 4598 if (*cmd == c)
4598 ++cmd; 4599 ++cmd;
4599 } 4600 }
4600 else 4601 else
4601 { 4602 {
4602 pos = curwin->w_cursor; /* save curwin->w_cursor */ 4603 int flags;
4603 /* 4604
4604 * When '/' or '?' follows another address, start 4605 pos = curwin->w_cursor; // save curwin->w_cursor
4605 * from there. 4606
4606 */ 4607 // When '/' or '?' follows another address, start from
4608 // there.
4607 if (lnum != MAXLNUM) 4609 if (lnum != MAXLNUM)
4608 curwin->w_cursor.lnum = lnum; 4610 curwin->w_cursor.lnum = lnum;
4609 /* 4611
4610 * Start a forward search at the end of the line (unless 4612 // Start a forward search at the end of the line (unless
4611 * before the first line). 4613 // before the first line).
4612 * Start a backward search at the start of the line. 4614 // Start a backward search at the start of the line.
4613 * This makes sure we never match in the current 4615 // This makes sure we never match in the current
4614 * line, and can match anywhere in the 4616 // line, and can match anywhere in the
4615 * next/previous line. 4617 // next/previous line.
4616 */
4617 if (c == '/' && curwin->w_cursor.lnum > 0) 4618 if (c == '/' && curwin->w_cursor.lnum > 0)
4618 curwin->w_cursor.col = MAXCOL; 4619 curwin->w_cursor.col = MAXCOL;
4619 else 4620 else
4620 curwin->w_cursor.col = 0; 4621 curwin->w_cursor.col = 0;
4621 searchcmdlen = 0; 4622 searchcmdlen = 0;
4622 if (!do_search(NULL, c, cmd, 1L, 4623 flags = silent ? 0 : SEARCH_HIS | SEARCH_MSG;
4623 SEARCH_HIS | SEARCH_MSG, NULL, NULL)) 4624 if (!do_search(NULL, c, cmd, 1L, flags, NULL, NULL))
4624 { 4625 {
4625 curwin->w_cursor = pos; 4626 curwin->w_cursor = pos;
4626 cmd = NULL; 4627 cmd = NULL;
4627 goto error; 4628 goto error;
4628 } 4629 }
9527 static void 9528 static void
9528 ex_copymove(exarg_T *eap) 9529 ex_copymove(exarg_T *eap)
9529 { 9530 {
9530 long n; 9531 long n;
9531 9532
9532 n = get_address(eap, &eap->arg, eap->addr_type, FALSE, FALSE, 1); 9533 n = get_address(eap, &eap->arg, eap->addr_type, FALSE, FALSE, FALSE, 1);
9533 if (eap->arg == NULL) /* error detected */ 9534 if (eap->arg == NULL) /* error detected */
9534 { 9535 {
9535 eap->nextcmd = NULL; 9536 eap->nextcmd = NULL;
9536 return; 9537 return;
9537 } 9538 }