mirror of
https://github.com/junegunn/fzf.vim.git
synced 2026-01-30 14:45:30 +08:00
Fix incorrect --query option in completion
s:complete_trigger should prepend the default options instead of
appending them. The bug was introduced in 25ea637.
/tmp/foo<ctrl-x><ctrl-f> should give fzf prompt "/tmp/" and default
query "foo". But it used to give "/tmp//tmp/foo".
This commit is contained in:
@@ -44,21 +44,34 @@ if s:is_win
|
||||
let s:bin.preview = 'bash '.escape(s:bin.preview, '\')
|
||||
endif
|
||||
|
||||
function! s:merge_opts(dict, eopts)
|
||||
function! s:extend_opts(dict, eopts, prepend)
|
||||
if empty(a:eopts)
|
||||
return
|
||||
endif
|
||||
if has_key(a:dict, 'options')
|
||||
if type(a:dict.options) == s:TYPE.list && type(a:eopts) == s:TYPE.list
|
||||
call extend(a:dict.options, a:eopts)
|
||||
if a:prepend
|
||||
let a:dict.options = extend(copy(a:eopts), a:dict.options)
|
||||
else
|
||||
call extend(a:dict.options, a:eopts)
|
||||
endif
|
||||
else
|
||||
let a:dict.options = join(map([a:dict.options, a:eopts], 'type(v:val) == s:TYPE.list ? join(map(copy(v:val), "fzf#shellescape(v:val)")) : v:val'))
|
||||
let all_opts = a:prepend ? [a:eopts, a:dict.options] : [a:dict.options, a:eopts]
|
||||
let a:dict.options = join(map(all_opts, 'type(v:val) == s:TYPE.list ? join(map(copy(v:val), "fzf#shellescape(v:val)")) : v:val'))
|
||||
endif
|
||||
else
|
||||
let a:dict.options = a:eopts
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:merge_opts(dict, eopts)
|
||||
return s:extend_opts(a:dict, a:eopts, 0)
|
||||
endfunction
|
||||
|
||||
function! s:prepend_opts(dict, eopts)
|
||||
return s:extend_opts(a:dict, a:eopts, 1)
|
||||
endfunction
|
||||
|
||||
" [[options to wrap], preview window expression, [toggle-preview keys...]]
|
||||
function! fzf#vim#with_preview(...)
|
||||
" Default options
|
||||
@@ -1173,7 +1186,7 @@ endfunction
|
||||
|
||||
function! s:complete_trigger()
|
||||
let opts = copy(s:opts)
|
||||
call s:merge_opts(opts, ['+m', '-q', s:query])
|
||||
call s:prepend_opts(opts, ['+m', '-q', s:query])
|
||||
let opts['sink*'] = s:function('s:complete_insert')
|
||||
let s:reducer = s:pluck(opts, 'reducer', s:function('s:first_line'))
|
||||
call fzf#run(opts)
|
||||
|
||||
Reference in New Issue
Block a user