junegunn / fzf.vim

fzf :heart: vim
MIT License
9.67k stars 585 forks source link

Setting autochdir and using Fzf breaks Fugitive commit capability #993

Open sim590 opened 4 years ago

sim590 commented 4 years ago

Problem

Using FZF to navigate to a file under subdirectory with the setting autochdir breaks directory dependant functionalities such as vim-fugitive.

To reproduce

$ mkdir /tmp && cd /tmp && git init
$ mkdir tata && echo "some stuff in this file" > tata/tutu # this is in a subdirectory
$ vim

Then, in Vim, use this configuration:

call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-fugitive'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
call plug#end()

filetype plugin indent on

set autochdir

and do the following:

:Files " select tata/tutu
:Gstatus
:Gcommit

Note that one can take the time to stage the files before running the last :Gcommit command while it does not have any incident on the following result which is an error one should not get at this point:

fatal: This operation must be run in a work tree

Important remarks

sim590 commented 4 years ago

Note that while I did mention that Ctrl-p would trigger the issue, the procedure to reproduce may not be so similar. Simply opening the file using Ctrl-p doesn't seem to trigger the issue, but that is not of big importance regarding the problem with Fzf.

wshanks commented 4 years ago

I opened an issue in the main fzf repo because I think the issue is in its vim plugin (which this vim plugin uses).