ibhagwan / fzf-lua

Improved fzf.vim written in lua
GNU Affero General Public License v3.0
2.15k stars 141 forks source link

Bug: actions.lua: attempt to index field '__CTX' (a nil value) #1414

Closed RaviRahar closed 3 weeks ago

RaviRahar commented 3 weeks ago

RTFM Checklist

Operating system

Linux

Shell

Bash

Neovim version (nvim --version)

NVIM v0.10.1

Fzf version (fzf --version)

0.54.3 (cf2242aea3)

Output of :lua print(os.getenv('FZF_DEFAULT_OPTS'))

nil

Is the problem reproducible with mini.sh?

Fzf-lua configuration

No response

Describe the bug / steps to reproduce

I think a nil check is needed here:
actions: 132: if vimcmd == "e" and (entry.uri or path.equals(fullpath, opts.__CTX.bname)) am I correct? I don't know if it should be possible for __CTX to be nil here and the issue might be pointing to some other issue but I do not have time to debug right now.

Full error:

[Fzf-lua] fn_selected threw an error: ...h/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/actions.lua:132: attempt to index field '__CTX' (a nil value)
stack traceback:                                                                                                                                           
^I...h/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:242: in function '__index'                                                                   
^I...h/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/actions.lua:132: in function <...h/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/actions.lua:117>           
^I...h/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/actions.lua:217: in function 'vimcmd_entry'                                                              
^I...h/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/actions.lua:224: in function 'file_edit'                                                                 
^I...al/share/nvim/lazy/fzf-combi-mode/lua/fzf-combi-mode.lua:516: in function 'action'                                                                    
^I...h/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/actions.lua:98: in function 'act'                                                                        
^I...h/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:148: in function 'fn_selected'                                                               
^I...h/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:235: in function <...h/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:234>           
^I[C]: in function 'xpcall'                                                                                                                                
^I...h/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:234: in function <...h/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:226> 
ibhagwan commented 3 weeks ago

I don't know if it should be possible for __CTX to be nil here and the issue might be pointing to some other issue but I do not have time to debug right now.

It shouldn’t be nil, what are the steps to reproduce this if you have such?

RaviRahar commented 3 weeks ago

It happens when I try to open file using my plugin. It happens on following line

ibhagwan commented 3 weeks ago

But does it happen on files buffers grep or on lsp_xxx calls? Does it always fail on every file or certain files?

If this was failing on all systems on all files I’m sure this would’ve been discovered already.

RaviRahar commented 3 weeks ago

It happens on all files. The function I mentioned lists contents if entry is a folder and opens it in new buffer it is file. It happens when I try to open any file.

ibhagwan commented 3 weeks ago

It happens when I try to open file using my plugin. It happens on following line

I understand now what you meant by “my plugin” , I’ll have to dig into your code later or tomorrow to see what’s happening.

RaviRahar commented 3 weeks ago

It was working alright a week or two before. So it is some recent change which has affected it

RaviRahar commented 3 weeks ago

It happens when I try to open file using my plugin. It happens on following line

I understand now what you meant by “my plugin” , I’ll have to dig into your code later or tomorrow to see what’s happening.

My guess is you do not need to read the whole code. Reading just the surrounding part should be enough. Everything else is kind of irrelevant

ibhagwan commented 3 weeks ago

It happens when I try to open file using my plugin. It happens on following line

I understand now what you meant by “my plugin” , I’ll have to dig into your code later or tomorrow to see what’s happening.

My guess is you do not need to read the whole code. Reading just the surrounding part should be enough. Everything else is kind of irrelevant

https://github.com/ibhagwan/fzf-lua/commit/c9c79bb8dfae5abe3bcdeca12e2469e9517195d0 - should work as before now.