ThePrimeagen / harpoon

MIT License
6.25k stars 348 forks source link

[harpoon2] when custom key is specified, persistent not working correctly #565

Open rusnasonov opened 2 months ago

rusnasonov commented 2 months ago

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

My harpoon setup:

harpoon:setup({
    settings = {
        save_on_toggle = true,
        sync_on_ui_close = true,
        key = function()
            local key = vim.fn.getcwd()
            local current_branch = utils.get_current_branch()
            if current_branch ~= nil then
                key = string.format("%s#%s", key, current_branch)
            end
            return key
        end
    }
})

I add and remove file to harpoon, but when i close and open nvim again, my harpoon list is empty.

ThePrimeagen commented 2 months ago

let me try this out and i'll see if we can get a quick fix for this

seems surprising!

gustavo-nakabayashi commented 2 months ago

same bug here

This is my setup:

harpoon:setup({
    settings = {
      save_on_toggle = true,
      sync_on_ui_close = false,
      key = function()
        local handle = io.popen("git rev-parse --abbrev-ref HEAD 2> /dev/null")
        local branch_name = handle:read("*a")
        handle:close()
        branch_name = string.gsub(branch_name, "\n", "")
        if branch_name == nil or branch_name == '' then
          return vim.loop.cwd()
        else
          return branch_name .. vim.loop.cwd()
        end
      end,
    },
  })
akyrey commented 2 months ago

Same problem with a similar configuration (different lists based on branch). It seems like the list is correctly saved but when opening a new instance of nvim the list isn't read and it's always displayed empty

rusnasonov commented 2 months ago

Problem with the_harpoon singleton. When module imported, singleton created, and using default key for data storage (vim.loop.cwd). Then when harpoon:setup called, default config updated, but data storage stay with default key

dajabe commented 1 month ago

Having this issue as well with a similar config, hoping that https://github.com/ThePrimeagen/harpoon/pull/557 can be merged soon