summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2019-03-28 10:50:38 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2019-03-28 13:57:04 +0900
commite7d60aac9cb7bd3c98d8ffd544f653278313bb56 (patch)
tree5be6a9332f1035069c6c886e38a20eafbc285668 /plugin
parenta0bfbdd49c8cd2cff948301273815ae728965e2b (diff)
downloadfzf-e7d60aac9cb7bd3c98d8ffd544f653278313bb56.tar.gz
[vim] Do not restore cwd when autochdir is set and buffer changed
Close #1539
Diffstat (limited to 'plugin')
-rw-r--r--plugin/fzf.vim5
1 files changed, 3 insertions, 2 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index e1047d04..8f2bc26a 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -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