Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Wrap input call to pcall to catch ctrl-c#38

Open
michurin wants to merge 1 commit intonvim-treesitter:masterfrom
michurin:master
Open

Wrap input call to pcall to catch ctrl-c#38
michurin wants to merge 1 commit intonvim-treesitter:masterfrom
michurin:master

Conversation

@michurin
Copy link

Wrap vim.*.input to pcall to avoid E5108: Error executing lua Keyboard interrupt error on CTRL-C

@theHamsta
Copy link
Member

This only seems to affect vim.fn.input. I would rather remove vim.fn.input only apply the change to vim.fn.input. Which implementation of vim.ui.input are you using?

@michurin
Copy link
Author

michurin commented Apr 7, 2023

Currently I use neovim 0.8.3. If I press C-c here

:lua vim.ui.input({prompt = ">"}, print)

i obtain this error:

E5108: Error executing lua Keyboard interrupt
stack traceback:
        [C]: in function 'input'
        /usr/share/nvim/runtime/lua/vim/ui.lua:91: in function 'input'
        [string ":lua"]:1: in main chunk

it is understandable and pcall helps:

:lua pcall(vim.ui.input, {prompt = ">"}, print)

However, you are right, it seems vim.fn.input already wrapped in 0.9.0 (vim.ui.input modern implementation). I'll play with 0.9 tomorrow. I see that pcall is not needed for 0.9. However, what do you think, is it good idea to keep it for neovims before 0.9?

upd: I've installed nvim 0.9, and I confirm, there is no more errors. So my pull request is not actual anymore. It is good for previous versions of nvim only.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants