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

Error: Attempt to index a nil value

Open ofseed opened this issue 11 months ago • 1 comments

Error executing vim.schedule lua callback: ...re/nvim/lazy/sentiment.nvim/lua/sentiment/ui/Portion.lua:69: attempt to index a nil value
stack traceback:
	...re/nvim/lazy/sentiment.nvim/lua/sentiment/ui/Portion.lua:69: in function 'get_current_char'
	...ocal/share/nvim/lazy/sentiment.nvim/lua/sentiment/ui.lua:64: in function 'find_pair'
	...ocal/share/nvim/lazy/sentiment.nvim/lua/sentiment/ui.lua:143: in function ''
	vim/_editor.lua: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>

I've found this bug for one year, but I can never reproduce it stably.

ofseed avatar Mar 20 '24 12:03 ofseed

Error executing vim.schedule lua callback: ...re/nvim/lazy/sentiment.nvim/lua/sentiment/ui/Portion.lua:69: attempt to index a nil value
stack traceback:
        ...re/nvim/lazy/sentiment.nvim/lua/sentiment/ui/Portion.lua:69: in function 'get_current_char'
        ...ocal/share/nvim/lazy/sentiment.nvim/lua/sentiment/ui.lua:64: in function 'find_pair'
        ...ocal/share/nvim/lazy/sentiment.nvim/lua/sentiment/ui.lua:143: in function ''
        vim/_editor.lua: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

@ofseed same bug here, but i can stably reproduce it:

  1. prepare 2 files:

debug.lua:

vim.opt.splitkeep = 'topline'

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

require("lazy").setup(
{
	{
		'utilyre/sentiment.nvim',
		init = function()
			vim.g.loaded_matchparen = 1
			vim.opt.showmatch = false
		end,
		config = function()
			require('sentiment').setup({
				included_modes = {
					n = true,
					i = true,
				},
				delay = 0,
			})
		end,
	},
},
{
}
)

dwm.c:

{
	some text
}
  1. run command nvim -u debug.lua dwm.c
  2. after opening the file dwm.c, press j to move down by 1 line
  3. press :h<CR> to open the help buffer
  4. error

note that after commenting out vim.opt.splitkeep = 'topline', this error won't happen

aidancz avatar Jul 27 '24 05:07 aidancz