Open Makaze opened 8 months ago
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 ~/:
cd
mkdir folder1
touch folder1/a.lua
touch folder1/b.lua
mkdir folder2
touch folder2/c.lua
cd folder1
nvim a.lua
harpoon:list():add()
to add a.lua
:q!
cd ~/folder2
nvim c.lua
harpoon:list():add()
to add c.lua
:cd ~/folder1
c.lua
:q!
cd ~/folder1
nvim
a.lua
-- original contents were preservedcd
mkdir folder1
touch folder1/a.lua
touch folder1/b.lua
cd folder1
nvim a.lua
harpoon:list():add()
to add a.lua
:q!
cd
nvim
:cd ~/folder1
:q!
cd ~/folder1
nvim
Ok this is what more interesting, let me double check this!!
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 masterPlease use
harpoon2
for branchSteps:
harpoon:list():add()
on a file:cd
(to home dir, or anything):q!