-
Notifications
You must be signed in to change notification settings - Fork 272
Description
Did you check docs and existing issues?
- I have read all the docs.
- I have searched the existing issues.
- I have searched the existing discussions.
Neovim Version (nvim -v)
NVIM v0.10.0-dev
Operating System / Version
wsl2 ubuntu-22.04
Describe the Bug
Hi guys, I found some errors when opening a new tabpage inside neo-tree (in my case a new tabpage of DiffView).
Here is the reproduce steps:
reproduce steps
_neovim.2023-06-30.00-36-56.mp4
Here is the captured stacktrace:
stacktrace
E5108: Error executing lua .../packer/start/neo-tree.nvim/lua/neo-tree/ui/selector.lua:224: attempt to index field 'tree' (a nil value)
stack traceback:
.../packer/start/neo-tree.nvim/lua/neo-tree/ui/selector.lua:224: in function 'get_scrolled_off_node_text'
.../packer/start/neo-tree.nvim/lua/neo-tree/ui/selector.lua:237: in function <.../packer/start/neo-tree.nvim/lua/neo-tree/ui/selector.lua:228>
The break occurs within the get_scrolled_off_node_text function, and the reason for the break is that state does not contain the tree member. After some deeper digging, I found that the reason is because the current tabpage(from vim.api.nvim_get_current_win) does not create a neo-tree when get_state_for_window is called.
Normally the require'neo-tree.ui.selector'.get() would be called from a created neo-tree tabpage. But in my case, when I opened the DiffView, it was probably some asynchronous initialization had not yet completed that caused this exception.
In my opinion, maybe we should add some checks to get_scrolled_off_node_text to enhance the robustness of the function, so that we can better catch exceptions that don't match our expectations.
So, I tried to do some small tests and try to fix this problem, which modified like this:
M.get_scrolled_off_node_text = function(state)
+ if state.tree == nil then
+ return
+ end
-- ....
endThis modification solves my problem. If you think this modification is positive, can you try to let me to fix it? I really like this plugin and would like to give some modest contribution. Otherwise, I would be willing and active to work with you to find out the deeper reasons for this problem.
Screenshots, Traceback
No response
Steps to Reproduce
Please see the trackback and video in description.
Expected Behavior
No breaks when opening diffview
Your Configuration
Just use the default settings, but set source_selector.winbar and source_selector.show_scrolled_off_parent_node to true.
I will add it in time if you think this is necessary.