When starting a new search none of the text is highlighted as expected. Then enable very magic (\v
) and suddenly all text is highlighted. I'd expect this to behave the same way as starting a new search.
Steps to reproduce:
$ vim -N -u NONE -c "set hlsearch incsearch" /path/to/file
Then type:
/\v
Expected result: nothing is highlighted
Actual result: entire buffer is highlighted
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
See also this discussion on vim_dev: https://groups.google.com/forum/#!topic/vim_dev/J61pNy137Iw
I made a patch, that goes on top of the fix for #2292
Please see those two commits:
Sorry there was an error. Here is an update:
See also this discussion on vim_dev: https://groups.google.com/forum/#!topic/vim_dev/J61pNy137Iw
I made a patch, that goes on top of the fix for #2292
Please see those two commits:
Awesome! Thanks @chrisbra!
I looked into the Vim source code before to fix this behavior, but I couldn't find how to fix it...
btw, will ^
or $
are highlighted? In incsearch.vim plugin, it suppress highlighting if the pattern is matched with zero width string, but it also turn off the highlight of ^
and $
.
btw, will ^ or $ are highlighted?
Interesting question. I was not sure, how is_zero_width would handle this. Trying it shows, that highlighting would be suppressed. I am unsure, whether this is correct or not.
Okay will fix it.
So how about the following commit:
chrisbra/vim@36e1a98
This works by checking from the start of the buffer whether the last typed pattern matches with zero-width (and again one position further, so that a pattern like \<
or ^
can still be highlighted, while e.g. \zs
won't be highlighted.) However this might potentially slow down Vim, because we have to do the check twice.
Here are some example patterns and some gotchas:
\zs
won't be highlighted\v
won't be highlighted\<
will be highlighted^
will be highlighted$
will be highlighted\|
won't be highlighted.
will be highlighted\(foo\)\|
will be highlightedThe last one might be surprising (and it is hard to fix), but I found it actually quite useful. Once you type a complex pattern and it suddenly highlights everything this gives some feedback that you either have made some error or are at a point in the pattern where it would match everything (and this shouldn't happen that often in practice to be really disturbing).
—
How about this instead: We don't highlight the matches until after a short delay, so it updates when the user pauses typing. Then you won't get all kind of fast flickering, but you do get to see all the matches after a short pause.
I am sorry, I don't know how to do this. You are not talking about the char_avail()
function right? Because that is already used in the incsearch code.
—
is this still relevant? I have been looking into this issue again and I am wondering, if this is still relevant and needs a patch or we should close it. There is the empty_pattern()
function now included with commit 6621605 which should theoretically alleviate this problem.
I have written a preliminary patch for using a timer for incsearch highlighting here chrisbra/vim@3b1b9cb
This is significantly better with Included patches: 1-1415
(which includes 6621605). The whole buffer isn't highlighted anymore.
There is however still a small difference between /
and /\v
in that the current cursor position is highlighted in the latter when it isn't in the former.
I would consider this issue closed, but since @chrisbra still has a commit against this, I'll leave it up to him to close it.
using my commit will change it how highlighting works when incsearch is set so much, that I would expect a couple of new issues coming in. However once you get used to that incsearch does not kick in immediately, but only after a small pause, it also makes sense. I leave this to Bram to decide whether we need this or not.
I am closing this. The mentioned patch breaks too many tests, so the patch is probably not correct.
Closed #2337.