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

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

Open
fent opened this issue May 27, 2023 · 5 comments

Comments

@fent
Copy link

fent commented May 27, 2023

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

@arsham
Copy link
Owner

arsham commented May 28, 2023

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?

@fent
Copy link
Author

fent commented Jul 19, 2023

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

@arsham
Copy link
Owner

arsham commented Aug 19, 2023

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.

@fent
Copy link
Author

fent commented Aug 22, 2023

maybe they populate the qflist in slightly different formats?

@arsham
Copy link
Owner

arsham commented Aug 22, 2023

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

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