Skip to content

Commit

Permalink
[vim] Throw error if g:fzf_layout is incorrectly used
Browse files Browse the repository at this point in the history
  • Loading branch information
junegunn committed Mar 2, 2017
1 parent 972fb1a commit 111d193
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion plugin/fzf.vim
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ function! s:defaults()
return empty(colors) ? '' : ('--color='.colors)
endfunction

function! s:validate_layout(layout)
for key in keys(a:layout)
if index(s:layout_keys, key) < 0
throw printf('invalid entry in g:fzf_layout: %s (allowed: %s)%s',
\ key, join(s:layout_keys, ', '), key == 'options' ? '. Use $FZF_DEFAULT_OPTS.' : '')
endif
endfor
return a:layout
endfunction

" [name string,] [opts dict,] [fullscreen boolean]
function! fzf#wrap(...)
let args = ['', {}, 0]
Expand Down Expand Up @@ -223,7 +233,7 @@ function! fzf#wrap(...)
if !exists('g:fzf_layout') && exists('g:fzf_height')
let opts.down = g:fzf_height
else
let opts = extend(opts, get(g:, 'fzf_layout', s:default_layout))
let opts = extend(opts, s:validate_layout(get(g:, 'fzf_layout', s:default_layout)))
endif
endif

Expand Down

0 comments on commit 111d193

Please sign in to comment.