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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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 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