airblade/vim-gitgutter

GitGutterLineHighlightsToggle doesn't update immediately on neovim

Closed this issue · 3 comments

Hi, I've noticed that on neovim built from the master branch :GitGutterLineHighlightsToggle doesn't take effect immediately, something needs to force gitgutter to update, for example calling :GitGutter (which I use as a workaround).

What is the latest commit SHA in your installed vim-gitgutter?

67ef116

What vim/nvim version are you on?

nvim d3e51603bc94fac68cd2c92ae7ebc90baa8471fe but the behavior started around a84b454ebe661981f292ee8fc73be4f9cd3a5884

Is this toggling from off to on or on to off or both?

Here's the implementation:

function! gitgutter#highlight#line_disable() abort
let g:gitgutter_highlight_lines = 0
call s:define_sign_line_highlights()
if !g:gitgutter_signs
call gitgutter#sign#clear_signs(bufnr(''))
endif
redraw!
endfunction
function! gitgutter#highlight#line_enable() abort
let old_highlight_lines = g:gitgutter_highlight_lines
let g:gitgutter_highlight_lines = 1
call s:define_sign_line_highlights()
if !old_highlight_lines && !g:gitgutter_signs
call gitgutter#all(1)
endif
redraw!
endfunction
function! gitgutter#highlight#line_toggle() abort
if g:gitgutter_highlight_lines
call gitgutter#highlight#line_disable()
else
call gitgutter#highlight#line_enable()
endif
endfunction

It depends on whether g:gitgutter_signs (whether to show signs) is on or off.

Both. Judging by the code, I guess sign define changes are not applied to already placed signs, until they are removed and placed again, so it's a neovim bug.

That sounds plausible to me.

I expect that writing a separate code path using extmarks would resolve this, but I don't really have time to do that at the moment.

Defining your own command which calls :GitGutterLineHighlightsToggle and then :GitGutter, i.e. your workaround, seems like the best way past this for now.