comparison src/ex_getln.c @ 14613:3f9b73cc8adb v8.1.0320

patch 8.1.0320: too much 'incsearch' highlight for pat matching everything commit https://github.com/vim/vim/commit/8b0d5ce881ac16a36ea00018ba13a58b0fdb7534 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Aug 22 23:05:44 2018 +0200 patch 8.1.0320: too much 'incsearch' highlight for pat matching everything Problem: Too much 'incsearch' highlight for pattern matching everything. Solution: Add the skiplen to the command and remove the line range. (Christian Brabandt) Check for empty pattern earlier.
author Christian Brabandt <cb@256bit.org>
date Wed, 22 Aug 2018 23:15:06 +0200
parents 5e038972cafa
children c6b41d47bac1
comparison
equal deleted inserted replaced
14612:de8371a98aff 14613:3f9b73cc8adb
283 int delim; 283 int delim;
284 char_u *end; 284 char_u *end;
285 char_u *dummy; 285 char_u *dummy;
286 exarg_T ea; 286 exarg_T ea;
287 pos_T save_cursor; 287 pos_T save_cursor;
288 int use_last_pat;
288 289
289 *skiplen = 0; 290 *skiplen = 0;
290 *patlen = ccline.cmdlen; 291 *patlen = ccline.cmdlen;
291 292
292 if (!p_is || cmd_silent) 293 if (!p_is || cmd_silent)
359 360
360 p = skipwhite(p); 361 p = skipwhite(p);
361 delim = (delim_optional && vim_isIDc(*p)) ? ' ' : *p++; 362 delim = (delim_optional && vim_isIDc(*p)) ? ' ' : *p++;
362 end = skip_regexp(p, delim, p_magic, NULL); 363 end = skip_regexp(p, delim, p_magic, NULL);
363 364
364 if (end == p && *end != delim) 365 use_last_pat = end == p && *end == delim;
366
367 if (end == p && !use_last_pat)
365 return FALSE; 368 return FALSE;
369
370 // Don't do 'hlsearch' highlighting if the pattern matches everything.
371 if (!use_last_pat)
372 {
373 char c = *end;
374 int empty;
375
376 *end = NUL;
377 empty = empty_pattern(p);
378 *end = c;
379 if (empty)
380 return FALSE;
381 }
382
366 // found a non-empty pattern or // 383 // found a non-empty pattern or //
367
368 *skiplen = (int)(p - ccline.cmdbuff); 384 *skiplen = (int)(p - ccline.cmdbuff);
369 *patlen = (int)(end - p); 385 *patlen = (int)(end - p);
370 386
371 // parse the address range 387 // parse the address range
372 save_cursor = curwin->w_cursor; 388 save_cursor = curwin->w_cursor;
553 is_state->match_end = end_pos; 569 is_state->match_end = end_pos;
554 curwin->w_cursor = save_pos; 570 curwin->w_cursor = save_pos;
555 } 571 }
556 else 572 else
557 end_pos = curwin->w_cursor; // shutup gcc 4 573 end_pos = curwin->w_cursor; // shutup gcc 4
558
559 // Disable 'hlsearch' highlighting if the pattern matches everything.
560 // Avoids a flash when typing "foo\|".
561 if (!use_last_pat)
562 {
563 next_char = ccline.cmdbuff[skiplen + patlen];
564 ccline.cmdbuff[skiplen + patlen] = NUL;
565 if (empty_pattern(ccline.cmdbuff))
566 set_no_hlsearch(TRUE);
567 ccline.cmdbuff[skiplen + patlen] = next_char;
568 }
569 574
570 validate_cursor(); 575 validate_cursor();
571 // May redraw the status line to show the cursor position. 576 // May redraw the status line to show the cursor position.
572 if (p_ru && curwin->w_status_height > 0) 577 if (p_ru && curwin->w_status_height > 0)
573 curwin->w_redr_status = TRUE; 578 curwin->w_redr_status = TRUE;