Open insidewhy opened 5 years ago
BTW tested this with neovim-fuzzy
as the only plugin enabled, and it still happened.
Here is my workaround:
fun s:FuzzyOpener(val)
let prev_tabpage = tabpagenr()
exe "tabe" a:val
let next_tabpage = tabpagenr()
exe "tabnext" prev_tabpage
lcd -
let dir = getcwd()
exe "tabnext" next_tabpage
exe "lcd" dir
" neovim-fuzzy will execute "lcd -" so ensure the previous directory is the
" one we want
lcd /tmp
endfun
command! -nargs=1 FuzzyOpener call s:FuzzyOpener(<q-args>)
let g:fuzzy_opencmd = 'FuzzyOpener'
It is dirty but it works.
The correct fix would be to change this bit of code: https://github.com/cloudhead/neovim-fuzzy/blob/53383395befafce802c902c21b54847074454491/plugin/neovim-fuzzy.vim#L221
It would have to store the current tab before running the open command, and then check if the tab has changed. When it has, then it should switch to the previous tab and run lcd
to the directory of the new tab, before switching back to the new tab.
Or alternatively it could just not lcd
at all and instead resolve the path to open with respect to self.root
.
This happens when
fuzzy_opencmd
is set totabe
(ortab drop
or any other command that opens the result in a new tab).e.g. say I am in a project called
project
inside subdirectorysubdir
which contains two files,file1
andfile2
.When I open the first file with neovim-fuzzy, say
file1
then thefile1
tab corrrectly hasproject/subdir
as itscwd
. Now if I open a second file while the file1 tab is focussed, sayfile2
then the new tab withfile2
in it has the correctcwd
ofproject/subdir
but thefile1
tab now has acwd
ofproject
.Then if I were to open a third file with
neovim-fuzzy
, while looking at thefile2
tab, now that tab will also have acwd
of the project root. It always sets thecwd
of the "current" tab to the project root.