mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-11-11 16:15:46 +00:00
[vim] Preserve current directory in case someone changes it (#2096)
Preserve current directory in case current directory is changed by others after the call of s:open Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
This commit is contained in:
parent
8e027c445f
commit
f79b1f71b8
@ -236,9 +236,13 @@ function! s:common_sink(action, lines) abort
|
|||||||
endif
|
endif
|
||||||
try
|
try
|
||||||
let empty = empty(s:fzf_expand('%')) && line('$') == 1 && empty(getline(1)) && !&modified
|
let empty = empty(s:fzf_expand('%')) && line('$') == 1 && empty(getline(1)) && !&modified
|
||||||
let autochdir = &autochdir
|
" Preserve the current working directory in case it's changed during
|
||||||
set noautochdir
|
" the execution (e.g. `set autochdir` or `autocmd BufEnter * lcd ...`)
|
||||||
|
let cwd = exists('w:fzf_pushd') ? w:fzf_pushd.dir : expand('%:p:h')
|
||||||
for item in a:lines
|
for item in a:lines
|
||||||
|
if item[0] != '~' && item !~ (s:is_win ? '^[A-Z]:\' : '^/')
|
||||||
|
let item = join([cwd, item], (s:is_win ? '\' : '/'))
|
||||||
|
endif
|
||||||
if empty
|
if empty
|
||||||
execute 'e' s:escape(item)
|
execute 'e' s:escape(item)
|
||||||
let empty = 0
|
let empty = 0
|
||||||
@ -252,7 +256,6 @@ function! s:common_sink(action, lines) abort
|
|||||||
endfor
|
endfor
|
||||||
catch /^Vim:Interrupt$/
|
catch /^Vim:Interrupt$/
|
||||||
finally
|
finally
|
||||||
let &autochdir = autochdir
|
|
||||||
silent! autocmd! fzf_swap
|
silent! autocmd! fzf_swap
|
||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
Loading…
Reference in New Issue
Block a user