Skip to content
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

Open
dylnmc opened this issue Dec 16, 2018 · 6 comments
Open

timer with highlight breaks IncSearch #3694

dylnmc opened this issue Dec 16, 2018 · 6 comments

Comments

@dylnmc
Copy link

dylnmc commented Dec 16, 2018

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 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 his 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 how IncSearch disappears when the statusline changes color. Here is the script:

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. 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

Cheers,
dylnmc

@brammool
Copy link
Contributor

brammool commented Dec 16, 2018 via email

@dylnmc
Copy link
Author

dylnmc commented Dec 16, 2018

I mean … sure I won't use highlight in a timer, since I don't need to. I don't know if you want me to close this issue or not. It still seems to be an issue, but it's definitely not an important issue or a time-sensitive one.

@dylnmc
Copy link
Author

dylnmc commented Jun 5, 2019

@brammool I just noticed (in 9.1 +1-956 so slightly older version) that terminals that update a lot (for example :terminal with weechat running, cause the same issue. Seems to slightly escalate the issue.

@brammool
Copy link
Contributor

brammool commented Jun 5, 2019

What do you mean with "makes IncSearch disappear"? Does the highlight group disappear?
I tried the example and a search highlight doesn't disappear, thus I don't understand the problem.

@dylnmc
Copy link
Author

dylnmc commented Aug 23, 2019

I had, for example, in a :terminal window weechat running and inside weechat there was a clock which updated every second. every time the timer changed IncSearch hl group disappeared. If the terminal doesn't update, then it appears not to break it. Also it might be a windows-only thing.

@GopherJ
Copy link

GopherJ commented Jul 6, 2020

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:

:hi clear IncSearch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants