Fix E728 in fzf#vim#colors() when called with a spec dict#1611
Open
MenkeTechnologies wants to merge 1 commit intojunegunn:masterfrom
Open
Fix E728 in fzf#vim#colors() when called with a spec dict#1611MenkeTechnologies wants to merge 1 commit intojunegunn:masterfrom
MenkeTechnologies wants to merge 1 commit intojunegunn:masterfrom
Conversation
The public API for fzf#vim#colors() accepts ([spec dict], [fullscreen bool]), but `if !a:1` on line 614 assumed a:1 is always a number. When a:1 is a dictionary (e.g. from a custom :Colors command override), Vim throws E728: Using a Dictionary as a Number. Add type check before the boolean test, matching how s:fzf() already handles the same varargs pattern. Fixes junegunn#1610
junegunn
reviewed
Apr 2, 2026
| \} | ||
|
|
||
| if !a:1 " We can't set up IPC in fullscreen mode in Vim | ||
| if a:0 && type(a:1) != s:TYPE.dict && !a:1 " We can't set up IPC in fullscreen mode in Vim |
Owner
There was a problem hiding this comment.
Since the function can take at most 2 arguments, the fullscreen flag may not be a:1 but a:2.
What do you think?
Suggested change
| if a:0 && type(a:1) != s:TYPE.dict && !a:1 " We can't set up IPC in fullscreen mode in Vim | |
| let fullscreen = a:0 && type(a:000[-1]) != s:TYPE.dict && a:000[-1] | |
| if !fullscreen " We can't set up IPC in fullscreen mode in Vim |
Test cases:
call fzf#vim#colors()
call fzf#vim#colors(0)
call fzf#vim#colors(1)
call fzf#vim#colors({})
call fzf#vim#colors({}, 0)
call fzf#vim#colors({}, 1)
Author
There was a problem hiding this comment.
looks resilient enough.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
fzf#vim#colors()throwsE728: Using a Dictionary as a Numberwhen called with a spec dict as the first argument:Line 614 does
if !a:1assuminga:1is always a number, but the documented API isfzf#vim#colors([spec dict], [fullscreen bool]).Fix
Add a type check before the boolean test, matching how
s:fzf()already handles the same varargs pattern:Fixes #1610