kylechui / nvim-surround

Add/change/delete surrounding delimiter pairs with ease. Written with :heart: in Lua.
MIT License
3.18k stars 62 forks source link

Highlights not cleared when cancelling `vim.ui.input` #85

Closed smjonas closed 2 years ago

smjonas commented 2 years ago

Checklist

Describe the bug When cancelling the vim.ui.input prompt, any created highlights will not be cleared and stay permanently in the buffer.

To Reproduce

  1. Move to any word in a buffer and type ysiwT.
  2. Press <C-c>.

Expected behavior The highlight should be cleared.

Additional context None

kylechui commented 2 years ago

Interesting... continuing the discussion here this seems like even more of a niche problem than I thought; this only happens when you use <C-c> to terminate the input, as opposed to <Esc> (which I normally use).

smjonas commented 2 years ago

I think this is just the way Neovim's vim.fn.input / vim.ui.input work in general: cancelling normally, i.e. by closing the command line (I mapped this to ii, works with <esc> by default) returns nil as an input. However, <C-c> as a keyboard interrupt is somehow considered an error. Maybe this behavior should be changed in Neovim / Vim itself.

kylechui commented 2 years ago

While I agree, I don't think that's going to be changed anytime soon for parity reasons with Vim haha, as vim.fn.input() is just an internal call to VimL's input()(to my knowledge).

Edit: vim.ui.input() is something completely different, which cannot be used for other reasons (namely, it's asynchronous nature).