Don't mutate args to fzf#vim#files() (#1282)

As the code was written before, if we do this:

   let s:opts = {
   \ 'window': {'width': 0.6, 'height': 0.6, 'relative': v:false},
   \ 'options': ['--layout=reverse', '--info=inline'],
   \}

   call fzf#vim#files('', s:opts, 0)

...then s:opts will get mutated by the call to fzf#vim#files, cloberring
any persistent configuration established this way.

Making a defensive copy solves the problem.
This commit is contained in:
Stefan Kanev
2021-05-09 07:45:33 +03:00
committed by GitHub
parent 75c7e87de1
commit a88311b222

View File

@@ -302,6 +302,7 @@ function! s:fzf(name, opts, extra)
throw 'invalid number of arguments'
endif
let extra = copy(extra)
let eopts = has_key(extra, 'options') ? remove(extra, 'options') : ''
let merged = extend(copy(a:opts), extra)
call s:merge_opts(merged, eopts)