Setting autochdir and using Fzf breaks Fugitive commit capability
- Dominant language
- Vim Script
- Stars
- 10.3k
- Forks
- 608
- Avg merge
- 5d 8h
- Merged PRs (30d)
- 2
Description
- [x] I have read through https://github.com/junegunn/fzf.vim/blob/master/README.md
- [x] I have read through https://github.com/junegunn/fzf/blob/master/README-VIM.md
- [ ] I have read through the manual page of fzf (`man fzf`)
- [x] I have earched through the existing issues
## Problem
Using FZF to navigate to a file under subdirectory with the setting `autochdir` breaks directory dependant functionalities such as [vim-fugitive][].
## To reproduce
```sh
$ 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:
```vim
: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
* Unsetting the `autochdir` option does go around the problem, i.e. that you can do a commit with the `:Gstatus` window without issue;
* Opening the file using means other than Fzf such as `:e` or even using the `:Startify` command from the [vim-startify][] plugin won't trigger this issue.
* This issue happened with [Ctrl-p][] as well before I switched to Fzf and I suspect that both projects are independantly responsible.
* This issue could be linked to https://github.com/tpope/vim-fugitive/issues/1195. Note that I may not have realized back when I commented on this last thread, but it seems like using either ctrl-p or Fzf to change file ended up causing the issue.
* Running `:pwd` inside the file window or in the `:Gstatus` window, in both cases, gives a sensible result. In the former case, you'd get `$ROOT/tata` and in the latter, you get `$ROOT/.git`.
[Ctrl-p]: https://github.com/kien/ctrlp.vim
[vim-fugitive]: https://github.com/tpope/vim-fugitive/
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.