listish.nvim icon indicating copy to clipboard operation
listish.nvim copied to clipboard

Getting an error after adding new item to quicklist and then opening another item

Open fent opened this issue 1 year ago • 5 comments

Hi! I'm getting the following error after I add an item to the quicklist using the default <leader>qq mapping. Afterwards, if I navigate to the quicklist and hit on another item I get this error:

Error detected while processing BufEnter Autocommands for "<buffer=14>":
Error executing lua callback: ...ocal/share/nvim/lazy/listish.nvim/lua/listish/visual.lua:63: Invalid 'line': out of range
stack traceback:
        [C]: in function 'nvim_buf_set_extmark'
        ...ocal/share/nvim/lazy/listish.nvim/lua/listish/visual.lua:63: in function 'insert_extmarks'
        ...ocal/share/nvim/lazy/listish.nvim/lua/listish/visual.lua:113: in function 'update_extmarks'
        ...ocal/share/nvim/lazy/listish.nvim/lua/listish/visual.lua:217: in function <...ocal/share/nvim/lazy/listish.nvim/lua/listish/visual.lua:213>

If I navigate to another quicklist item using :cnext or :cprevious I get another error

E5108: Error executing lua: vim/_editor.lua:0: nvim_exec2()..BufEnter Autocommands for "<buffer=14>": Vim(append):Error executing lua callback: ...ocal/share/nvim/lazy
/listish.nvim/lua/listish/visual.lua:63: Invalid 'line': out of range
stack traceback:
        [C]: in function 'nvim_buf_set_extmark'
        ...ocal/share/nvim/lazy/listish.nvim/lua/listish/visual.lua:63: in function 'insert_extmarks'
        ...ocal/share/nvim/lazy/listish.nvim/lua/listish/visual.lua:113: in function 'update_extmarks'
        ...ocal/share/nvim/lazy/listish.nvim/lua/listish/visual.lua:217: in function <...ocal/share/nvim/lazy/listish.nvim/lua/listish/visual.lua:213>
        [C]: in function 'nvim_exec2'
        vim/_editor.lua: in function 'cmd'
        ...local/share/nvim/lazy/arshlib.nvim/lua/arshlib/quick.lua:32: in function 'cmd_and_centre'
        ....local/share/nvim/lazy/listish.nvim/lua/listish/init.lua:228: in function <....local/share/nvim/lazy/listish.nvim/lua/listish/init.lua:227>
stack traceback:
        [C]: in function 'nvim_exec2'
        vim/_editor.lua: in function 'cmd'
        ...local/share/nvim/lazy/arshlib.nvim/lua/arshlib/quick.lua:32: in function 'cmd_and_centre'
        ....local/share/nvim/lazy/listish.nvim/lua/listish/init.lua:228: in function <....local/share/nvim/lazy/listish.nvim/lua/listish/init.lua:227>

I'm also getting a glitched looking buffer of the file afterwards, with "Quickfix Note" appended to the lines that were previously in the quickfix list but not added through this plugin image

So I think it's getting confused with items that were already there

fent avatar May 27 '23 21:05 fent

Thanks for raising this issue.

May I ask what version of Neovim you are using?

When you produce the glitch, is there any Zs in the qf buffer? Those items indicate which entry is created by the user. This is an example:

listish

Basically, this plugin should not add any extmarks/signs for anything that don't have a Z in there.

Can you provide a minimal config with step by step process to produce these errors please?

arsham avatar May 28 '23 11:05 arsham

neovim version: v0.9.0

to reproduce:

  • save the following as repro.lua
-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/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", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  -- add any other plugins here
  {
    "arsham/listish.nvim",
    dependencies = {
      "arsham/arshlib.nvim",
      -- "nvim-treesitter/nvim-treesitter-textobjects",
    },
    ft = "qf",
    opts = true,
  },
  {
    "nvim-telescope/telescope.nvim",
    dependencies = { "nvim-lua/plenary.nvim" },
    keys = {
      { "<C-p>", "<cmd>lua require('telescope.builtin').live_grep()<cr>" },
    },
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
  • run nvim -u repro.lua
  • press <ctrl-p> to open telescope search
  • search for something that shows some results
  • press <ctrl-q> to place results in qflist
  • select first result
  • move the cursor to another line and press \qq to add it to the qflist
  • focus the qflist
  • select another item
  • see error

fent avatar Jul 19 '23 08:07 fent

I'm afraid I couldn't find the root cause of this bug. My guess is that the Telescope does something with the buffer that is not supposed to, but I can't be sure. I've done many tests with FZF and Telescope, everytime FZF works but the Telescope doesn't.

arsham avatar Aug 19 '23 11:08 arsham

maybe they populate the qflist in slightly different formats?

fent avatar Aug 22 '23 04:08 fent

I don't think it is possible. The setqflist has a very specific set of input.

arsham avatar Aug 22 '23 21:08 arsham