New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
timer with highlight breaks IncSearch #3694
Comments
With the handy assistance of a kind soul, who goes by the name
`m_ben`, on freenode/#vim, we have deduced that a timer that
repeatedly calls `highlight` makes `IncSearch` disappear when the
timer's callback is called. For example, if you have a timer that
repeatedly calls this every 200 ms or so, then you try to search for
something with `/set` (for example), then `IncSearch` disappears when
the timer is called. At first I thought it was the timer's fault, but
it appears to happen only when `highlight` is issued. Therefore, it
seems to be `hi`s fault.
What follows is a simple script that will cause the issue. In order to
run it, copy the code below, open a new vim buffer, run `:setf vim` to
change the filetype to *vim*, then save it with, for example, `:w
/tmp/foo.vim', and finally run `:source %`. Here is the script:
```vim
let s:state = 0
function! BlinkStatus(timer) abort
if s:state == 0
highlight StatusLine ctermbg=22 ctermfg=244 guibg=#005f00 guifg=#808080
let s:state = 1
else
highlight StatusLine ctermfg=22 ctermbg=244 guifg=#005f00 guibg=#808080
let s:state = 0
endif
endfunction
let timer = timer_start(500, 'BlinkStatus', {'repeat': -1})
```
In order to test before I knew exactly what the issue is, I also made a small repository on gitlab that illustrates the problem: [gitlab repo](https://gitlab.com/dylnmc/vim-timer-test). In order to run **that**, just:
1. **BE SURE TO SAVE YOUR OWN ~/.vimrc AND ~/.vim**
2. `git clone https://gitlab.com/dylnmc/vim-timer-test ~/.vim`
3. `vim` and `:PlugDownload`
4. `:XMas`
5. Search for something ... notice how it breaks whenever you type any character in the search line
---
It doesn't matter unless you're version is pre 8.0, but my version is
8.1 with patches 1-591
Hmm, using :highlight from a timer will trigger a complete redraw, since
Vim assumes something changed color. That means any temporary
highlighting or text will be overwritten.
This will be hard to avoid. I would suggest you don't change
highlighting in a timer.
…--
For a moment, nothing happened.
Then, after a second or so, nothing continued to happen.
-- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
I mean … sure I won't use |
@brammool I just noticed (in 9.1 +1-956 so slightly older version) that terminals that update a lot (for example |
What do you mean with "makes IncSearch disappear"? Does the highlight group disappear? |
I had, for example, in a |
I'm wondering if this is related: https://files.gitter.im/5c7cd365d73408ce4fb98b75/K5kE/Peek-2020-07-06-11-46.gif I have this issue in vim8.2 but not in neovim, I fixed it using:
|
Hello,
With the handy assistance of a kind soul, who goes by the name
m_ben
, on freenode/#vim, we have deduced that a timer that repeatedly callshighlight
makesIncSearch
disappear when the timer's callback is called. For example, if you have a timer that repeatedly calls this every 200 ms or so, then you try to search for something with/set
(for example), thenIncSearch
disappears when the timer is called. At first I thought it was the timer's fault, but it appears to happen only whenhighlight
is issued. Therefore, it seems to behi
s fault.What follows is a simple script that will cause the issue. In order to run it, copy the code below; open a new vim buffer; run
:setf vim
to change the filetype to vim; then save it with, for example,:w /tmp/foo.vim
; run:source %
; and finally, try to search for something (for example/state
) and notice howIncSearch
disappears when the statusline changes color. Here is the script:In order to test before I knew exactly what the issue is, I also made a small repository on gitlab that illustrates the problem: gitlab repo. In order to run that, just:
git clone https://gitlab.com/dylnmc/vim-timer-test ~/.vim
vim
and:PlugDownload
:XMas
It doesn't matter unless you're version is pre 8.0, but my version is 8.1 with patches 1-591
Cheers,
dylnmc
The text was updated successfully, but these errors were encountered: