Yggdroot / LeaderF

An efficient fuzzy finder that helps to locate files, buffers, mrus, gtags, etc. on the fly for both vim and neovim.
Apache License 2.0
2.14k stars 180 forks source link

git diff --current-file 会切换工作目录 #1078

Closed keeferwu closed 2 months ago

keeferwu commented 2 months ago

当项目中存在多个git时 git diff --current-file 会自动切换目录

项目结构:

root_git
---  .git
---  sub1_git
     --- .git
     --- bbb.c

在 root_git dir 下打开并修改bbb.c 使用leader git diff --current-file, 工作目录会被切到sub1_git 使用leader git diff 工作目录就不会发生变化

Yggdroot commented 2 months ago

这是https://github.com/Yggdroot/LeaderF/issues/1066 引入的,有什么问题吗?

keeferwu commented 2 months ago

g:Lf_GitWorkingDirectoryMode 我使用的默认值 'f' 不应该自动切换工作目录 leader git diff --current-file 应该 leader git diff 保持一致

Yggdroot commented 2 months ago

在我电脑上是一致的,不知道为什么你电脑上不一致。

在 root_git dir 下打开并修改bbb.c 使用leader git diff --current-file, 工作目录会被切到sub1_git 使用leader git diff 工作目录就不会发生变化

在 root_git dir 下打开并修改bbb.c ,此时执行py3 print(vim.current.buffer.name), 再执行leader git diff --current-file,使用 leader git diff 之前也执行py3 print(vim.current.buffer.name)看看。

keeferwu commented 2 months ago

我的项目中 \~/cameo/cetacea 为项目根,含有一个.git \~/cameo/cetacea/core/code 为子项目,含有一个.git 我对~/cameo/cetacea/core/code/future/LR/lrmain.c 做一些修改

执行 leaderf git diff: PixPin_2024-06-15_14-11-31

执行 leaderf git diff --current-file:

PixPin_2024-06-15_14-18-24

Yggdroot commented 2 months ago

明白了,是有点问题。 leaderf git diff的行为是正常的,退出后恢复到原来的路径。 而 leaderf git diff --current-file 退出后没有恢复。