diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2016-01-12 01:15:36 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2016-01-12 01:15:36 +0900 |
commit | 0f281ef89410cd581b581fd6087e9edd1832d1e8 (patch) | |
tree | e74db6aee7f9528bacf76cc05636f77508a5b1c4 /test | |
parent | b18db4733c635705b3aa052efe91472432727c58 (diff) |
[vim] Try to make 'dir' option compatible with &autochdir
When 'dir' option is passed to fzf#run(), the current working directory
is temporarily changed to the given directory, and restored at the end.
However, this behavior is not compatible with &autochdir. This commit
introduces a heuristic to determine whether or not to restore the
previous working directory.
Related: https://github.com/junegunn/fzf.vim/issues/70
Diffstat (limited to 'test')
-rw-r--r-- | test/fzf.vader | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/fzf.vader b/test/fzf.vader index c27fddc8..78bc6c59 100644 --- a/test/fzf.vader +++ b/test/fzf.vader @@ -1,6 +1,7 @@ Execute (Setup): let g:dir = fnamemodify(g:vader_file, ':p:h') Log 'Test directory: ' . g:dir + Save &acd Execute (fzf#run with dir option): let cwd = getcwd() @@ -35,6 +36,34 @@ Execute (fzf#run with string source): let result = sort(fzf#run({ 'source': 'echo hi', 'options': '-f i' })) AssertEqual ['hi'], result +Execute (fzf#run with dir option and noautochdir): + set noacd + let cwd = getcwd() + call fzf#run({'source': ['/foobar'], 'sink': 'e', 'dir': '/tmp', 'options': '-1'}) + " No change in working directory + AssertEqual cwd, getcwd() + +Execute (Incomplete fzf#run with dir option and autochdir): + set acd + let cwd = getcwd() + call fzf#run({'source': [], 'sink': 'e', 'dir': '/tmp', 'options': '-0'}) + " No change in working directory even if &acd is set + AssertEqual cwd, getcwd() + +Execute (fzf#run with dir option and autochdir): + set acd + let cwd = getcwd() + call fzf#run({'source': ['/foobar'], 'sink': 'e', 'dir': '/tmp', 'options': '-1'}) + " Working directory changed due to &acd + AssertEqual '/', getcwd() + +Execute (fzf#run with dir option and autochdir when final cwd is same as dir): + set acd + cd /tmp + call fzf#run({'source': ['/foobar'], 'sink': 'e', 'dir': '/', 'options': '-1'}) + " Working directory changed due to &acd + AssertEqual '/', getcwd() + Execute (Cleanup): unlet g:dir Restore |