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

fix completion error #819

Merged
merged 1 commit into from
May 23, 2023
Merged

fix completion error #819

merged 1 commit into from
May 23, 2023

Conversation

tzachar
Copy link
Contributor

@tzachar tzachar commented May 23, 2023

When Lazy commands are searched in command line mode, completion fails horribly (sometime crashing nvim entirely) when the partial string to complete contains non-escape characters.
For example, running :Lazy up[ results in a crash.

The fix is to instruct string.find to perform a literal search, treating the string to search not as a regular expression.

When Lazy commands are searched in command line mode, completion fails
horribly (sometime crashing nvim entirely) when the partial string to
complete contains non-escape characters.
For example, running `:Lazy up[` results in a crash.

The fix is to instruct string.find to perform a literal search, treating
the string to search not as a regular expression.
@folke folke merged commit f125a7d into folke:main May 23, 2023
@folke
Copy link
Owner

folke commented May 23, 2023

Merged, but I didnt' have this issue?

@tzachar
Copy link
Contributor Author

tzachar commented May 23, 2023

It was triggered from within nvim-cmp for me:

:Lazy up[                                                                                                                                                                     
Error executing vim.schedule lua callback: Vim:E5108: Error executing Lua function: ...cal/share/nvim/lazy/lazy.nvim/lua/lazy/view/commands.lua:116: malformed pattern (missin
g ']')                                                                                                                                                                        
stack traceback:                                                                                                                                                              
        [C]: in function 'find'                                                                                                                                               
        ...cal/share/nvim/lazy/lazy.nvim/lua/lazy/view/commands.lua:116: in function <...cal/share/nvim/lazy/lazy.nvim/lua/lazy/view/commands.lua:114>                        
        vim/shared.lua: in function <vim/shared.lua:0>                                                                                                                        
        [C]: in function 'getcompletion'                                                                                                                                      
        ...cal/share/nvim/lazy/cmp-cmdline/lua/cmp_cmdline/init.lua:124: in function 'exec'                                                                                   
        ...cal/share/nvim/lazy/cmp-cmdline/lua/cmp_cmdline/init.lua:175: in function 'complete'                                                                               
        ...achar/.local/share/nvim/lazy/nvim-cmp/lua/cmp/source.lua:334: in function 'complete'                                                                               
        ...tzachar/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:289: in function 'complete'                                                                               
        ...tzachar/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:169: in function 'autoindent'                                                                             
        ...tzachar/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:161: in function 'on_change'                                                                              
        ...tzachar/.local/share/nvim/lazy/nvim-cmp/lua/cmp/init.lua:313: in function 'callback'                                                                               
        .../.local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/async.lua:138: in function <.../.local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/async.lua:136>                

@folke
Copy link
Owner

folke commented May 23, 2023

Odd, must be a bug in CMP cmdline then

@tzachar
Copy link
Contributor Author

tzachar commented May 23, 2023

I don't think so.
The following also triggers the bug:

:echo getcompletion("Lazy up[", "cmdline")

results in

E5108: Error executing Lua function: ...cal/share/nvim/lazy/lazy.nvim/lua/lazy/view/commands.lua:116: malformed pattern (missing ']')                                         
stack traceback:                                                                                                                                                              
        [C]: in function 'find'                                                                                                                                               
        ...cal/share/nvim/lazy/lazy.nvim/lua/lazy/view/commands.lua:116: in function <...cal/share/nvim/lazy/lazy.nvim/lua/lazy/view/commands.lua:114>                        
        vim/shared.lua: in function <vim/shared.lua:0>                                                      

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

Successfully merging this pull request may close these issues.

None yet

2 participants