Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(bug) Opening the quickmenu after starting vim from '~/' then :cd to a dir deletes the list at that path #553

Open
Makaze opened this issue Apr 4, 2024 · 3 comments

Comments

@Makaze
Copy link

Makaze commented Apr 4, 2024

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:

  1. Open nvim from ~/some/path/
  2. Call harpoon:list():add() on a file
  3. Open the harpoon menu, see addition
  4. :cd (to home dir, or anything)
  5. Open harpoon menu, see nothing
  6. Close menu.
  7. :q!
  8. Reopen vim in same path
  9. Open harpoon menu, see nothing
Makaze added a commit to Makaze/harpoon that referenced this issue Apr 4, 2024
@ThePrimeagen
Copy link
Owner

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

@Makaze
Copy link
Author

Makaze commented Apr 5, 2024

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 ~/:

asciicast

Normal experience:

Steps:

  1. Setup:
cd
mkdir folder1
touch folder1/a.lua
touch folder1/b.lua
mkdir folder2
touch folder2/c.lua
cd folder1
nvim a.lua
  1. Call harpoon:list():add() to add a.lua
  2. Open the harpoon menu, see addition
  3. :q!
cd ~/folder2
nvim c.lua
  1. Open harpoon menu, see nothing
  2. Call harpoon:list():add() to add c.lua
  3. :cd ~/folder1
  4. Open harpoon menu, see c.lua
  5. :q!
cd ~/folder1
nvim
  1. Open harpoon menu, see a.lua -- original contents were preserved

The Bug

Steps:

  1. Setup:
cd
mkdir folder1
touch folder1/a.lua
touch folder1/b.lua
cd folder1
nvim a.lua
  1. Call harpoon:list():add() to add a.lua
  2. Open the harpoon menu, see addition
  3. :q!
cd
nvim
  1. Open harpoon menu, see nothing
  2. :cd ~/folder1
  3. Open harpoon menu, see nothing
  4. :q!
cd ~/folder1
nvim
  1. Open harpoon menu, see nothing -- original contents were overwritten or cleared

@Makaze Makaze changed the title (bug) Opening the quickmenu after :cd within vim overwrites the original list instead of the new path (bug) Opening the quickmenu after starting vim from '~/' then :cd to a dir deletes the list at that path Apr 5, 2024
@ThePrimeagen
Copy link
Owner

Ok this is what more interesting, let me double check this!!

@ThePrimeagen ThePrimeagen reopened this Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants