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

Closing buffer while 'Outline' is open throws errors

Open idelice opened this issue 1 year ago • 16 comments

Describe the bug

14:29:10 msg_show Error executing lua callback: ...ocal/share/nvim/lazy/lspsaga.nvim/lua/lspsaga/window.lua:154: 'width' key must be a positive Integer
stack traceback:
	[C]: in function 'nvim_open_win'
	...ocal/share/nvim/lazy/lspsaga.nvim/lua/lspsaga/window.lua:154: in function 'new_float'
	...re/nvim/lazy/lspsaga.nvim/lua/lspsaga/symbol/outline.lua:351: in function 'create_preview_win'
	...re/nvim/lazy/lspsaga.nvim/lua/lspsaga/symbol/outline.lua:423: in function <...re/nvim/lazy/lspsaga.nvim/lua/lspsaga/symbol/outline.lua:408>

Steps to reproduce

  1. open a file
  2. enable outline
  3. close that file

Expected behavior

I expect that the outline should just close alongside that file. Not throwing errors.

Neovim version (nvim -v)

latest

lspsaga commit

latest

Terminal name/version

kitty

idelice avatar Oct 09 '23 12:10 idelice

@glepnir still happens:

   Error  13:48:21 msg_show.lua_error Error executing Lua callback: ...re/nvim/lazy/lspsaga.nvim/lua/lspsaga/symbol/outline.lua:30: Invalid 'group': 128
stack traceback:
	[C]: in function 'nvim_get_autocmds'
	...re/nvim/lazy/lspsaga.nvim/lua/lspsaga/symbol/outline.lua:30: in function 'clean_ctx'
	...re/nvim/lazy/lspsaga.nvim/lua/lspsaga/symbol/outline.lua:559: in function 'outline'
	...share/nvim/lazy/lspsaga.nvim/lua/lspsaga/symbol/init.lua:222: in function 'outline'
	...cal/share/nvim/lazy/lspsaga.nvim/lua/lspsaga/command.lua:50: in function <...cal/share/nvim/lazy/lspsaga.nvim/lua/lspsaga/command.lua:49>
	...cal/share/nvim/lazy/lspsaga.nvim/lua/lspsaga/command.lua:74: in function 'load_command'
	...e/.local/share/nvim/lazy/lspsaga.nvim/plugin/lspsaga.lua:8: in function <...e/.local/share/nvim/lazy/lspsaga.nvim/plugin/lspsaga.lua:7>

idelice avatar Oct 16 '23 11:10 idelice

I can't reproduce with you reproduce now

1. open a file
2. open outline
3. move cursor back to file
4. close file

glepnir avatar Oct 16 '23 11:10 glepnir

Try this

  1. open two files
  2. navigate to either one
  3. open outline
  4. cursor on file
  5. close outline

idelice avatar Oct 16 '23 11:10 idelice

if buffer delete then the outline also delete is reasonable? this way easy to solve issue.

glepnir avatar Oct 16 '23 12:10 glepnir

If that's the fix, go for it, but what could be nice to have is:

While outline is on inside file, and you close that file it should either:

  1. Stay open and be updated with the new file your cursor is inside
  2. Close when no files available

idelice avatar Oct 16 '23 12:10 idelice

yes ..that's the correct way.. but a bit trouble . let me try some change tho.

glepnir avatar Oct 16 '23 12:10 glepnir

yes ..that's the correct way.. but a bit trouble . let me try some change tho.

I updated my latest comment

idelice avatar Oct 16 '23 12:10 idelice

a simple test when you open two window when close buffer in one window it will jump to another window ..

glepnir avatar Oct 16 '23 12:10 glepnir

a simple test when you open two window when close buffer in one window it will jump to another window ..

Yes if another file exists otherwise outline should close

idelice avatar Oct 16 '23 12:10 idelice

So this is where it gets tricky. if can keep window not close it's easy to do.

glepnir avatar Oct 16 '23 13:10 glepnir

Let's split it up in two:

  1. bug fix
  2. enchanement

right now, just close outline if file closes.

then, if time and resources, focus on the enhancement which is the tricky part.

What do you say?

idelice avatar Oct 16 '23 13:10 idelice

maybe can use bd# to keep window not close then do refresh .. but there have a bug i need find it out tomorrow.

glepnir avatar Oct 16 '23 13:10 glepnir

Encountered the same issue.

  1. Open a file
  2. Lspsaga outline
  3. back cursor to the file
  4. press q to quit the file, an error has occurred.

Perhaps it's because I used mini.bufremove in Lazyvim.

yifan0414 avatar Jan 25 '24 00:01 yifan0414

Hitting this error:

Error detected while processing WinEnter Autocommands for "*":
Error executing lua callback: ...re/nvim/lazy/lspsaga.nvim/lua/lspsaga/symbol/outline.lua:30: Invalid 'group': 52
stack traceback:
        [C]: in function 'nvim_get_autocmds'
        ...re/nvim/lazy/lspsaga.nvim/lua/lspsaga/symbol/outline.lua:30: in function 'clean_ctx'
        ...re/nvim/lazy/lspsaga.nvim/lua/lspsaga/symbol/outline.lua:494: in function <...re/nvim/lazy/lspsaga.nvim/lua/lspsaga/symbol/outline.lua:490>

I think it's because of deleting the augroup before calling clean_ctx https://github.com/nvimdev/lspsaga.nvim/blob/b1b140aa20a0cf353cd3e282870429b48b30a169/lua/lspsaga/symbol/outline.lua#L493-L494

Since clean_ctx tries to look up autocmds by the group id https://github.com/nvimdev/lspsaga.nvim/blob/b1b140aa20a0cf353cd3e282870429b48b30a169/lua/lspsaga/symbol/outline.lua#L26-L36

zlstringham avatar Feb 25 '24 22:02 zlstringham

@glepnir I think my commit above addresses this error, which has more to do with referencing a deleted augroup.

However, I'm unable to consistently reproduce or understand this error also shown below. Sometimes it occurs and other times it doesn't. I believe it happens because the auto close check fails leaving the outline buffer as the last window. Then the preview window rendering fails because its width arg becomes 0. Somehow this condition can be met without actually triggering the creation of the scratch buffer in place of the outline. Maybe it has to do with the choice of autocommand event? Thoughts?

Error detected while processing CursorMoved Autocommands for "<buffer=25>":
Error executing lua callback: ...uments/code/nvim-dev/lspsaga.nvim/lua/lspsaga/window.lua:157: 'width' key must be a positive Integer
stack traceback:
        [C]: in function 'nvim_open_win'
        ...uments/code/nvim-dev/lspsaga.nvim/lua/lspsaga/window.lua:157: in function 'new_float'
        ...ode/nvim-dev/lspsaga.nvim/lua/lspsaga/symbol/outline.lua:374: in function 'create_preview_win'
        ...ode/nvim-dev/lspsaga.nvim/lua/lspsaga/symbol/outline.lua:452: in function <...ode/nvim-dev/lspsaga.nvim/lua/lspsaga/symbol/outline.lua:433>

winter-again avatar Mar 05 '24 07:03 winter-again

Actually looks like #api.nvim_list_wins() == 1 condition is failing. Not sure why the list of window handles isn't properly tracking. It will still show multiple window handles despite me only having a single window open. Might have to try with a more minimal config to make sure something else isn't the problem.

winter-again avatar Mar 05 '24 07:03 winter-again