nvim-treesitter / nvim-treesitter-refactor

Refactor module for nvim-treesitter
Apache License 2.0
407 stars 25 forks source link

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

Open michurin opened 2 years ago

michurin commented 2 years ago

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

theHamsta commented 1 year ago

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 commented 1 year ago

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.