harpoon
harpoon copied to clipboard
(bug) Opening the quickmenu after starting vim from '~/' then `:cd` to a dir deletes the list at that path
WARNING
If this is about Harpoon1, the issue will be closed. All support and everything of harpoon1 will be frozen on master
until 4/20 or 6/9 and then harpoon2 will become master
Please use harpoon2
for branch
Steps:
- Open nvim from ~/some/path/
- Call
harpoon:list():add()
on a file - Open the harpoon menu, see addition
-
:cd
(to home dir, or anything) - Open harpoon menu, see nothing
- Close menu.
-
:q!
- Reopen vim in same path
- Open harpoon menu, see nothing
this is how it should have always worked in harpoon2
if you change your directory you create a new hash. if for whatever we have changed that, then its my fault i let bad behavior exist
If you wish to emulate that behavior, do this ( i haven't tested this, but it "should" work")
local cwd = vim.loop.cwd()
harpoon:setup({
settings = {
key = function() return cwd end
}
})
effectively, by executing cd, you have changed cwd
in vim.loop.cwd() which is used to calculate which harpoon you are using.
so the script above takes the FIRST cwd and uses it as the permanent one
I was able to confirm this bug actually only occurs with the home directory. All other directories work fine as you intended, but for some reason, :cd
from within user home breaks it.
Demo, first normal, then starting from ~/:
Normal experience:
Steps:
- Setup:
cd
mkdir folder1
touch folder1/a.lua
touch folder1/b.lua
mkdir folder2
touch folder2/c.lua
cd folder1
nvim a.lua
- Call
harpoon:list():add()
to adda.lua
- Open the harpoon menu, see addition
-
:q!
cd ~/folder2
nvim c.lua
- Open harpoon menu, see nothing
- Call
harpoon:list():add()
to addc.lua
-
:cd ~/folder1
- Open harpoon menu, see
c.lua
-
:q!
cd ~/folder1
nvim
- Open harpoon menu, see
a.lua
-- original contents were preserved
The Bug
Steps:
- Setup:
cd
mkdir folder1
touch folder1/a.lua
touch folder1/b.lua
cd folder1
nvim a.lua
- Call
harpoon:list():add()
to adda.lua
- Open the harpoon menu, see addition
-
:q!
cd
nvim
- Open harpoon menu, see nothing
-
:cd ~/folder1
- Open harpoon menu, see nothing
-
:q!
cd ~/folder1
nvim
- Open harpoon menu, see nothing -- original contents were overwritten or cleared
Ok this is what more interesting, let me double check this!!