[vim] Code cleanup
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Junegunn Choi · committed by Junegunn Choi · parent 57319f8 · Browse files · 2 files·+15 added−18 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+15 added−18 removed
- tests:+6 added−3 removed
- other:+9 added−15 removed
Provenance
- Commit
68503d3- Tree
92e7243- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
57319f8
2 files changed+15 added−18 removed
modified:plugin/fzf.vim+9 added-15 removed
123 unmodified lines124 endif125 let split = s:tmux_enabled() && s:tmux_splittable(dict)126 let command = prefix.(split ? s:fzf_tmux(dict) : fzf_exec).' '.optstr.' > '.temps.result127 128+ try128- if split129- return s:execute_tmux(dict, command, temps)130- else131- return s:execute(dict, command, temps)132- endif129+ if split130+ return s:execute_tmux(dict, command, temps)131+ else132+ return s:execute(dict, command, temps)133+ endif134+ finally135+ call s:popd(dict)136+ endtry137 endfunction138 139 function! s:present(dict, ...)140 for key in a:00057 unmodified lines198 return s:callback(a:dict, a:temps)199 endif200 endfunction201 198-function! s:env_var(name)199- if exists('$'.a:name)200- return a:name . "='". substitute(expand('$'.a:name), "'", "'\\\\''", 'g') . "' "201- else202- return ''203- endif204-endfunction205-202 function! s:execute_tmux(dict, command, temps)203 let command = a:command204 if s:pushd(a:dict)205 " -c '#{pane_current_path}' is only available on tmux 1.9 or above23 unmodified lines229 for tf in values(a:temps)230 silent! call delete(tf)231 endfor232 237- call s:popd(a:dict)238-233 return lines234 endfunction235 236 function! s:cmd(bang, ...) abort41 unmodified linesmodified:test/fzf.vader+6 added-3 removed
1 unmodified line2 let g:dir = fnamemodify(g:vader_file, ':p:h')3 Log 'Test directory: ' . g:dir4 5 Execute (fzf#run with dir option):6+ let cwd = getcwd()7 let result = fzf#run({ 'options': '--filter=vdr', 'dir': g:dir })8 AssertEqual ['fzf.vader'], result9+ AssertEqual getcwd(), cwd10 11 let result = sort(fzf#run({ 'options': '--filter e', 'dir': g:dir }))10- AssertEqual ['fzf.vader', 'test_go.rb', 'test_ruby.rb'], result12+ AssertEqual ['fzf.vader', 'test_go.rb'], result13+ AssertEqual getcwd(), cwd14 15 Execute (fzf#run with Funcref command):16 let g:ret = []17 function! g:FzfTest(e)18 call add(g:ret, a:e)19 endfunction20 let result = sort(fzf#run({ 'sink': function('g:FzfTest'), 'options': '--filter e', 'dir': g:dir }))18- AssertEqual ['fzf.vader', 'test_go.rb', 'test_ruby.rb'], result19- AssertEqual ['fzf.vader', 'test_go.rb', 'test_ruby.rb'], sort(g:ret)21+ AssertEqual ['fzf.vader', 'test_go.rb'], result22+ AssertEqual ['fzf.vader', 'test_go.rb'], sort(g:ret)23 24 Execute (fzf#run with string source):25 let result = sort(fzf#run({ 'source': 'echo hi', 'options': '-f i' }))26 AssertEqual ['hi'], result14 unmodified lines