[vim] Code cleanup
This commit is contained in:
parent
57319f8c58
commit
68503d32df
@ -125,11 +125,15 @@ function! fzf#run(...) abort
|
|||||||
let split = s:tmux_enabled() && s:tmux_splittable(dict)
|
let split = s:tmux_enabled() && s:tmux_splittable(dict)
|
||||||
let command = prefix.(split ? s:fzf_tmux(dict) : fzf_exec).' '.optstr.' > '.temps.result
|
let command = prefix.(split ? s:fzf_tmux(dict) : fzf_exec).' '.optstr.' > '.temps.result
|
||||||
|
|
||||||
|
try
|
||||||
if split
|
if split
|
||||||
return s:execute_tmux(dict, command, temps)
|
return s:execute_tmux(dict, command, temps)
|
||||||
else
|
else
|
||||||
return s:execute(dict, command, temps)
|
return s:execute(dict, command, temps)
|
||||||
endif
|
endif
|
||||||
|
finally
|
||||||
|
call s:popd(dict)
|
||||||
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:present(dict, ...)
|
function! s:present(dict, ...)
|
||||||
@ -195,14 +199,6 @@ function! s:execute(dict, command, temps)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:env_var(name)
|
|
||||||
if exists('$'.a:name)
|
|
||||||
return a:name . "='". substitute(expand('$'.a:name), "'", "'\\\\''", 'g') . "' "
|
|
||||||
else
|
|
||||||
return ''
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:execute_tmux(dict, command, temps)
|
function! s:execute_tmux(dict, command, temps)
|
||||||
let command = a:command
|
let command = a:command
|
||||||
if s:pushd(a:dict)
|
if s:pushd(a:dict)
|
||||||
@ -234,8 +230,6 @@ function! s:callback(dict, temps)
|
|||||||
silent! call delete(tf)
|
silent! call delete(tf)
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
call s:popd(a:dict)
|
|
||||||
|
|
||||||
return lines
|
return lines
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -3,11 +3,14 @@ Execute (Setup):
|
|||||||
Log 'Test directory: ' . g:dir
|
Log 'Test directory: ' . g:dir
|
||||||
|
|
||||||
Execute (fzf#run with dir option):
|
Execute (fzf#run with dir option):
|
||||||
|
let cwd = getcwd()
|
||||||
let result = fzf#run({ 'options': '--filter=vdr', 'dir': g:dir })
|
let result = fzf#run({ 'options': '--filter=vdr', 'dir': g:dir })
|
||||||
AssertEqual ['fzf.vader'], result
|
AssertEqual ['fzf.vader'], result
|
||||||
|
AssertEqual getcwd(), cwd
|
||||||
|
|
||||||
let result = sort(fzf#run({ 'options': '--filter e', 'dir': g:dir }))
|
let result = sort(fzf#run({ 'options': '--filter e', 'dir': g:dir }))
|
||||||
AssertEqual ['fzf.vader', 'test_go.rb', 'test_ruby.rb'], result
|
AssertEqual ['fzf.vader', 'test_go.rb'], result
|
||||||
|
AssertEqual getcwd(), cwd
|
||||||
|
|
||||||
Execute (fzf#run with Funcref command):
|
Execute (fzf#run with Funcref command):
|
||||||
let g:ret = []
|
let g:ret = []
|
||||||
@ -15,8 +18,8 @@ Execute (fzf#run with Funcref command):
|
|||||||
call add(g:ret, a:e)
|
call add(g:ret, a:e)
|
||||||
endfunction
|
endfunction
|
||||||
let result = sort(fzf#run({ 'sink': function('g:FzfTest'), 'options': '--filter e', 'dir': g:dir }))
|
let result = sort(fzf#run({ 'sink': function('g:FzfTest'), 'options': '--filter e', 'dir': g:dir }))
|
||||||
AssertEqual ['fzf.vader', 'test_go.rb', 'test_ruby.rb'], result
|
AssertEqual ['fzf.vader', 'test_go.rb'], result
|
||||||
AssertEqual ['fzf.vader', 'test_go.rb', 'test_ruby.rb'], sort(g:ret)
|
AssertEqual ['fzf.vader', 'test_go.rb'], sort(g:ret)
|
||||||
|
|
||||||
Execute (fzf#run with string source):
|
Execute (fzf#run with string source):
|
||||||
let result = sort(fzf#run({ 'source': 'echo hi', 'options': '-f i' }))
|
let result = sort(fzf#run({ 'source': 'echo hi', 'options': '-f i' }))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user