Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When open a file with fzf, $PWD isn't changed #70

Closed
iven opened this issue Jan 11, 2016 · 9 comments
Closed

When open a file with fzf, $PWD isn't changed #70

iven opened this issue Jan 11, 2016 · 9 comments
Labels

Comments

@iven
Copy link

iven commented Jan 11, 2016

I have autochdir option set. When I open a file use split, or with ctrlp, $PWD is automatically changed as expected. But with fzf.vim, it doesn't change.

@junegunn
Copy link
Owner

Thanks for the report. But I can't seem to reproduce the problem. Check if the problem is reproducible with the following config:

call plug#begin('~/.vim/plugged')
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
call plug#end()

set autochdir
vim -Nu <(curl https://gist.githubusercontent.com/junegunn/3db3e26b85c76f76d889/raw/e574dc52f47005f3fa2ad67d3bdb455b7d31d01e/gistfile1.txt)

@iven
Copy link
Author

iven commented Jan 11, 2016

Yes, it's reproducible here. BTW, I'm using neovim 0.1.1, with :PlugUpdate succeeded.

@junegunn
Copy link
Owner

Strange. Which command did you use? Please provide the exact steps to reproduce the issue.

@junegunn
Copy link
Owner

Note that $PWD is not affected by autochdir with or without fzf. Check the output of :pwd or :echo getcwd() instead.

@iven
Copy link
Author

iven commented Jan 11, 2016

@junegunn I found that only :GitFiles command has this issue, :Files works as expected. The steps:

$ vim -Nu <(curl https://gist.githubusercontent.com/junegunn/3db3e26b85c76f76d889/raw/e574dc52f47005f3fa2ad67d3bdb455b7d31d01e/gistfile1.txt)
<:GitFiles>
// Select a file in the subfolder
<Enter>
<:pwd>
// $PWD remains the origin directory

@junegunn
Copy link
Owner

Ah, I see what's going on. You'll see the same issue when you pass directory argument to :Files command. e.g. :Files ..

This should be fixed in the main repo.

@junegunn
Copy link
Owner

junegunn/fzf@b18db47

The above commit should fix the problem. Thanks for the report.

@junegunn junegunn added the bug label Jan 11, 2016
@junegunn
Copy link
Owner

Hmm, let me check a few more things.

@junegunn junegunn reopened this Jan 11, 2016
junegunn added a commit to junegunn/fzf that referenced this issue Jan 11, 2016
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: junegunn/fzf.vim#70
@junegunn
Copy link
Owner

It should work as expected now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants