Error detected while processing function quick_scope#Ready[17]..<SNR>29_handle_extra_highlight[11]..<SNR>29_reset_saved_secondary_highlight:
line 5:
E416: missing equal sign: Define
this error only happens when g:qs_highlight_on_keys is set and the QuickScopeSecondary links to another group. Seems the bug triggers when the character highlighted with the secondary group is the last one before the end of line.
e.g. if the buffer content is like this:
foo 1 bar 1
with the cursor at the beginning of the line, typing f1f1f1 triggers the error, or
also from the beginning of the line typing f1lf
My vimscript foo is not great, but my guess is that somehow s:save_secondary_highlight() is not always called in this case, so when s:reset_saved_secondary_highlight() jumps in, it tries to restore the highlight group using the old value of s:saved_secondary_highlight (which has been modified by the substitute call in the previous call) failing.
As a workaround for now I'm storing the result of the substitute call on a local var, so that s:saved_secondary_highlight always contain a valid value:
diff --git a/autoload/quick_scope.vim b/autoload/quick_scope.vim
index 79140251611f..cba7d4a5de38 100644
--- a/autoload/quick_scope.vim
+++ b/autoload/quick_scope.vim
@@ -354,8 +354,8 @@ endfunction
" of a double_tap
function! s:reset_saved_secondary_highlight() abort
if s:saved_secondary_highlight =~# '^links to '
- let s:saved_secondary_highlight = substitute(s:saved_secondary_highlight, '^links to ', '', '')
- execute 'highlight! link ' . g:qs_hi_group_secondary . ' ' . s:saved_secondary_highlight
+ let l:saved_secondary_highlight = substitute(s:saved_secondary_highlight, '^links to ', '', '')
+ execute 'highlight! link ' . g:qs_hi_group_secondary . ' ' . l:saved_secondary_highlight
else
execute 'highlight ' . g:qs_hi_group_secondary . ' ' . s:saved_secondary_highlight
endif
Here's the minimal vimrc I've used:
set nocompatible
call plug#begin('~/.vim/plugged')
Plug 'unblevable/quick-scope'
call plug#end()
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
The error I get is the following:
this error only happens when g:qs_highlight_on_keys is set and the QuickScopeSecondary links to another group. Seems the bug triggers when the character highlighted with the secondary group is the last one before the end of line. e.g. if the buffer content is like this:
foo 1 bar 1
with the cursor at the beginning of the line, typing f1f1f1 triggers the error, or also from the beginning of the line typing f1lfMy vimscript foo is not great, but my guess is that somehow s:save_secondary_highlight() is not always called in this case, so when s:reset_saved_secondary_highlight() jumps in, it tries to restore the highlight group using the old value of s:saved_secondary_highlight (which has been modified by the substitute call in the previous call) failing.
As a workaround for now I'm storing the result of the substitute call on a local var, so that s:saved_secondary_highlight always contain a valid value:
Here's the minimal vimrc I've used: