[vim] Do not restore cwd when autochdir is set and buffer changed

Close #1539
This commit is contained in:
Junegunn Choi 2019-03-28 10:50:38 +09:00
parent a0bfbdd49c
commit e7d60aac9c
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -457,7 +457,8 @@ function! s:pushd(dict)
let cwd = s:fzf_getcwd()
let w:fzf_pushd = {
\ 'command': haslocaldir() ? 'lcd' : (exists(':tcd') && haslocaldir(-1) ? 'tcd' : 'cd'),
\ 'origin': cwd
\ 'origin': cwd,
\ 'bufname': bufname('')
\ }
execute 'lcd' s:escape(a:dict.dir)
let cwd = s:fzf_getcwd()
@ -493,7 +494,7 @@ function! s:dopopd()
" matches 'dir' entry. However, it is possible that the sink function did
" change the directory to 'dir'. In that case, the user will have an
" unexpected result.
if s:fzf_getcwd() ==# w:fzf_pushd.dir
if s:fzf_getcwd() ==# w:fzf_pushd.dir && (!&autochdir || w:fzf_pushd.bufname ==# bufname(''))
execute w:fzf_pushd.command s:escape(w:fzf_pushd.origin)
endif
unlet w:fzf_pushd