Mercurial > vim
comparison src/ex_getln.c @ 13035:89e191a2a8a7 v8.0.1393
patch 8.0.1393: too much highlighting with 'hlsearch' and 'incsearch' set
commit https://github.com/vim/vim/commit/6621605eb97cf5fbc481282fd4d349a76e168f16
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Dec 16 16:33:44 2017 +0100
patch 8.0.1393: too much highlighting with 'hlsearch' and 'incsearch' set
Problem: Too much highlighting with 'hlsearch' and 'incsearch' set.
Solution: Do not highlight matches when the pattern matches everything.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 16 Dec 2017 16:45:04 +0100 |
parents | 004bc78c88e6 |
children | 5f3aff09d8f8 |
comparison
equal
deleted
inserted
replaced
13034:7608b10442d9 | 13035:89e191a2a8a7 |
---|---|
168 ccline.cmdbuff = NULL; | 168 ccline.cmdbuff = NULL; |
169 if (msg_scrolled == 0) | 169 if (msg_scrolled == 0) |
170 compute_cmdrow(); | 170 compute_cmdrow(); |
171 MSG(""); | 171 MSG(""); |
172 redraw_cmdline = TRUE; | 172 redraw_cmdline = TRUE; |
173 } | |
174 | |
175 /* | |
176 * Guess that the pattern matches everything. Only finds specific cases, such | |
177 * as a trailing \|, which can happen while typing a pattern. | |
178 */ | |
179 static int | |
180 empty_pattern(char_u *p) | |
181 { | |
182 int n = STRLEN(p); | |
183 | |
184 /* remove trailing \v and the like */ | |
185 while (n >= 2 && p[n - 2] == '\\' | |
186 && vim_strchr((char_u *)"mMvVcCZ", p[n - 1]) != NULL) | |
187 n -= 2; | |
188 return n == 0 || (n >= 2 && p[n - 2] == '\\' && p[n - 1] == '|'); | |
173 } | 189 } |
174 | 190 |
175 /* | 191 /* |
176 * getcmdline() - accept a command line starting with firstc. | 192 * getcmdline() - accept a command line starting with firstc. |
177 * | 193 * |
2021 curwin->w_cursor = save_pos; | 2037 curwin->w_cursor = save_pos; |
2022 } | 2038 } |
2023 else | 2039 else |
2024 end_pos = curwin->w_cursor; /* shutup gcc 4 */ | 2040 end_pos = curwin->w_cursor; /* shutup gcc 4 */ |
2025 | 2041 |
2042 /* Disable 'hlsearch' highlighting if the pattern matches | |
2043 * everything. Avoids a flash when typing "foo\|". */ | |
2044 if (empty_pattern(ccline.cmdbuff)) | |
2045 SET_NO_HLSEARCH(TRUE); | |
2046 | |
2026 validate_cursor(); | 2047 validate_cursor(); |
2027 /* May redraw the status line to show the cursor position. */ | 2048 /* May redraw the status line to show the cursor position. */ |
2028 if (p_ru && curwin->w_status_height > 0) | 2049 if (p_ru && curwin->w_status_height > 0) |
2029 curwin->w_redr_status = TRUE; | 2050 curwin->w_redr_status = TRUE; |
2030 | 2051 |