Skip to content

Commit d0c6385

Browse files
committed
Handle only bg or fg set when resolving cursor hl
The previous code to resolve the cursor highlight didn't allow for only the background or foreground to be set, i.e. only one of guifg & guibg. This was done intentionally to keep the code simple, on the assumption that only setting either background or foreground was so rare that it didn't warrant the additional complexity, but it seems that assumption was misguided, while it is unusual, it's not rare enough to ignore. See #84 for background Thanks @casr for reporting this and researching in some detail :-)
1 parent f424831 commit d0c6385

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

autoload/fuzzyy/utils/popup.vim

+14-6
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,27 @@ def ResolveCursor()
6464
gui: { 'reverse': true },
6565
}
6666
var attrs = hlget('Cursor', true)->get(0, {})
67-
if !attrs->get('guifg') || !attrs->get('guibg')
67+
if !attrs->get('guifg') && !attrs->get('guibg')
6868
hlset([fallback])
6969
return
7070
endif
71-
var special = ['NONE', 'bg', 'fg', 'background', 'foreground']
72-
var guifg = attrs->get('guifg')
73-
var guibg = attrs->get('guibg')
71+
var special = ['bg', 'fg', 'background', 'foreground']
72+
var guifg = attrs->get('guifg', 'NONE')
73+
var guibg = attrs->get('guibg', 'NONE')
74+
if has('gui')
75+
hlset([{name: 'fuzzyyCursor', guifg: guifg, guibg: guibg}])
76+
return
77+
endif
7478
if index(special, guifg) != -1 || index(special, guibg) != -1
7579
hlset([fallback])
7680
return
7781
endif
78-
var ctermfg = attrs->get('ctermfg', string(colors.TermColor(guifg)))
79-
var ctermbg = attrs->get('ctermbg', string(colors.TermColor(guibg)))
82+
var ctermfg = attrs->get('ctermfg',
83+
guifg ==# 'NONE' ? 'NONE' : string(colors.TermColor(guifg))
84+
)
85+
var ctermbg = attrs->get('ctermbg',
86+
guibg ==# 'NONE' ? 'NONE' : string(colors.TermColor(guibg))
87+
)
8088
try
8189
hlset([{
8290
name: 'fuzzyyCursor',

0 commit comments

Comments
 (0)