Mercurial > vim
comparison src/ex_getln.c @ 18693:d7c47e45bcc3 v8.1.2338
patch 8.1.2338: using Visual mark sith :s gives E20 if not set
Commit: https://github.com/vim/vim/commit/c672525b487992306f69ceab093291ba3b8e4246
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Nov 23 21:56:46 2019 +0100
patch 8.1.2338: using Visual mark sith :s gives E20 if not set
Problem: Using Visual mark sith :s gives E20 if not set.
Solution: Ignore errors when handling 'incsearch'. (closes https://github.com/vim/vim/issues/3837)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 23 Nov 2019 22:00:04 +0100 |
parents | fd95d4dbeb37 |
children | ac08c7ad9d37 |
comparison
equal
deleted
inserted
replaced
18692:e83c4f346222 | 18693:d7c47e45bcc3 |
---|---|
195 char_u *end; | 195 char_u *end; |
196 char *dummy; | 196 char *dummy; |
197 exarg_T ea; | 197 exarg_T ea; |
198 pos_T save_cursor; | 198 pos_T save_cursor; |
199 int use_last_pat; | 199 int use_last_pat; |
200 int retval = FALSE; | |
200 | 201 |
201 *skiplen = 0; | 202 *skiplen = 0; |
202 *patlen = ccline.cmdlen; | 203 *patlen = ccline.cmdlen; |
203 | 204 |
204 if (!p_is || cmd_silent) | 205 if (!p_is || cmd_silent) |
211 if (firstc == '/' || firstc == '?') | 212 if (firstc == '/' || firstc == '?') |
212 return TRUE; | 213 return TRUE; |
213 if (firstc != ':') | 214 if (firstc != ':') |
214 return FALSE; | 215 return FALSE; |
215 | 216 |
217 ++emsg_off; | |
216 vim_memset(&ea, 0, sizeof(ea)); | 218 vim_memset(&ea, 0, sizeof(ea)); |
217 ea.line1 = 1; | 219 ea.line1 = 1; |
218 ea.line2 = 1; | 220 ea.line2 = 1; |
219 ea.cmd = ccline.cmdbuff; | 221 ea.cmd = ccline.cmdbuff; |
220 ea.addr_type = ADDR_LINES; | 222 ea.addr_type = ADDR_LINES; |
222 parse_command_modifiers(&ea, &dummy, TRUE); | 224 parse_command_modifiers(&ea, &dummy, TRUE); |
223 cmdmod = save_cmdmod; | 225 cmdmod = save_cmdmod; |
224 | 226 |
225 cmd = skip_range(ea.cmd, NULL); | 227 cmd = skip_range(ea.cmd, NULL); |
226 if (vim_strchr((char_u *)"sgvl", *cmd) == NULL) | 228 if (vim_strchr((char_u *)"sgvl", *cmd) == NULL) |
227 return FALSE; | 229 goto theend; |
228 | 230 |
229 // Skip over "substitute" to find the pattern separator. | 231 // Skip over "substitute" to find the pattern separator. |
230 for (p = cmd; ASCII_ISALPHA(*p); ++p) | 232 for (p = cmd; ASCII_ISALPHA(*p); ++p) |
231 ; | 233 ; |
232 if (*skipwhite(p) == NUL) | 234 if (*skipwhite(p) == NUL) |
233 return FALSE; | 235 goto theend; |
234 | 236 |
235 if (STRNCMP(cmd, "substitute", p - cmd) == 0 | 237 if (STRNCMP(cmd, "substitute", p - cmd) == 0 |
236 || STRNCMP(cmd, "smagic", p - cmd) == 0 | 238 || STRNCMP(cmd, "smagic", p - cmd) == 0 |
237 || STRNCMP(cmd, "snomagic", MAX(p - cmd, 3)) == 0 | 239 || STRNCMP(cmd, "snomagic", MAX(p - cmd, 3)) == 0 |
238 || STRNCMP(cmd, "vglobal", p - cmd) == 0) | 240 || STRNCMP(cmd, "vglobal", p - cmd) == 0) |
246 { | 248 { |
247 // skip over flags | 249 // skip over flags |
248 while (ASCII_ISALPHA(*(p = skipwhite(p)))) | 250 while (ASCII_ISALPHA(*(p = skipwhite(p)))) |
249 ++p; | 251 ++p; |
250 if (*p == NUL) | 252 if (*p == NUL) |
251 return FALSE; | 253 goto theend; |
252 } | 254 } |
253 else if (STRNCMP(cmd, "vimgrep", MAX(p - cmd, 3)) == 0 | 255 else if (STRNCMP(cmd, "vimgrep", MAX(p - cmd, 3)) == 0 |
254 || STRNCMP(cmd, "vimgrepadd", MAX(p - cmd, 8)) == 0 | 256 || STRNCMP(cmd, "vimgrepadd", MAX(p - cmd, 8)) == 0 |
255 || STRNCMP(cmd, "lvimgrep", MAX(p - cmd, 2)) == 0 | 257 || STRNCMP(cmd, "lvimgrep", MAX(p - cmd, 2)) == 0 |
256 || STRNCMP(cmd, "lvimgrepadd", MAX(p - cmd, 9)) == 0 | 258 || STRNCMP(cmd, "lvimgrepadd", MAX(p - cmd, 9)) == 0 |
259 // skip over "!" | 261 // skip over "!" |
260 if (*p == '!') | 262 if (*p == '!') |
261 { | 263 { |
262 p++; | 264 p++; |
263 if (*skipwhite(p) == NUL) | 265 if (*skipwhite(p) == NUL) |
264 return FALSE; | 266 goto theend; |
265 } | 267 } |
266 if (*cmd != 'g') | 268 if (*cmd != 'g') |
267 delim_optional = TRUE; | 269 delim_optional = TRUE; |
268 } | 270 } |
269 else | 271 else |
270 return FALSE; | 272 goto theend; |
271 | 273 |
272 p = skipwhite(p); | 274 p = skipwhite(p); |
273 delim = (delim_optional && vim_isIDc(*p)) ? ' ' : *p++; | 275 delim = (delim_optional && vim_isIDc(*p)) ? ' ' : *p++; |
274 end = skip_regexp(p, delim, p_magic, NULL); | 276 end = skip_regexp(p, delim, p_magic, NULL); |
275 | 277 |
276 use_last_pat = end == p && *end == delim; | 278 use_last_pat = end == p && *end == delim; |
277 | 279 |
278 if (end == p && !use_last_pat) | 280 if (end == p && !use_last_pat) |
279 return FALSE; | 281 goto theend; |
280 | 282 |
281 // Don't do 'hlsearch' highlighting if the pattern matches everything. | 283 // Don't do 'hlsearch' highlighting if the pattern matches everything. |
282 if (!use_last_pat) | 284 if (!use_last_pat) |
283 { | 285 { |
284 char c = *end; | 286 char c = *end; |
286 | 288 |
287 *end = NUL; | 289 *end = NUL; |
288 empty = empty_pattern(p); | 290 empty = empty_pattern(p); |
289 *end = c; | 291 *end = c; |
290 if (empty) | 292 if (empty) |
291 return FALSE; | 293 goto theend; |
292 } | 294 } |
293 | 295 |
294 // found a non-empty pattern or // | 296 // found a non-empty pattern or // |
295 *skiplen = (int)(p - ccline.cmdbuff); | 297 *skiplen = (int)(p - ccline.cmdbuff); |
296 *patlen = (int)(end - p); | 298 *patlen = (int)(end - p); |
319 search_first_line = curwin->w_cursor.lnum; | 321 search_first_line = curwin->w_cursor.lnum; |
320 search_last_line = curwin->w_cursor.lnum; | 322 search_last_line = curwin->w_cursor.lnum; |
321 } | 323 } |
322 | 324 |
323 curwin->w_cursor = save_cursor; | 325 curwin->w_cursor = save_cursor; |
324 return TRUE; | 326 retval = TRUE; |
327 theend: | |
328 --emsg_off; | |
329 return retval; | |
325 } | 330 } |
326 | 331 |
327 static void | 332 static void |
328 finish_incsearch_highlighting( | 333 finish_incsearch_highlighting( |
329 int gotesc, | 334 int gotesc, |