ThePrimeagen / harpoon

MIT License
6.25k stars 348 forks source link

Deleting marks from middle of the list breaks telescope extension #588

Open waduhek opened 1 month ago

waduhek commented 1 month ago

Description of the issue

After adding multiple marks and deleting one or more of them from the middle of the list, the telescope extension does not display the rest of the marks after the deleted mark.

Reproduction steps

  1. Add 3 or more marks to the harpoon list.
  2. Delete any mark from the middle of the list using the telescope finder. Any mark apart from the last mark should do.
  3. Check the list of marks again in the telescope finder.

Log file

config_default#create_list_item lua/harpoon/ui.lua
HarpoonList:add { index = -1, item = { context = { col = 0, row = 1 }, value = "lua/harpoon/ui.lua" } }
config_default#create_list_item lua/harpoon/autocmd.lua
HarpoonList:add { index = -1, item = { context = { col = 0, row = 1 }, value = "lua/harpoon/autocmd.lua" } }
config_default#create_list_item lua/harpoon/config.lua
HarpoonList:add { index = -1, item = { context = { col = 0, row = 1 }, value = "lua/harpoon/config.lua" } }
config_default#BufLeave updating position 7 lua/harpoon/config.lua { context = { col = 0, row = 1 }, value = "lua/harpoon/config.lua" } to position { 1, 0 }
HarpoonList:remove { index = 2, item = { context = { col = 0, row = 1 }, value = "lua/harpoon/autocmd.lua" } }

Neovim Version

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1713773202

Minimal Config

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "https://github.com/folke/lazy.nvim.git",
        "--branch=stable",
        lazypath,
    })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
    {
        "nvim-telescope/telescope.nvim",
        tag = "0.1.5",
        dependencies = {
            "nvim-lua/plenary.nvim",
        },
    },
    {
        "ThePrimeagen/harpoon",
        branch = "harpoon2",
        dependencies = {
            "nvim-lua/plenary.nvim",
            "nvim-telescope/telescope.nvim",
        },
        config = function ()
            require("telescope").load_extension("harpoon")
        end
    },
})

local harpoon = require("harpoon")
local telescope = require("telescope")

harpoon:setup()

vim.keymap.set(
    "n",
    "<leader>a",
    function()
        harpoon:list():add()
    end
)

vim.keymap.set("n", "<C-q>", telescope.extensions.harpoon.marks)

Additional context

This could be related to #555. But since that issue doesn't mention the telescope extension I thought of creating a new issue for it.

A workaround that I've found is to open the harpoon quick menu and delete the mark from there to get telescope to show the rest of the marks. Additionally, the harpoon quick menu shows a blank line for where the mark used be.