Closed xiaochuanyu closed 1 year ago
What version of Neovim are you using? If you're using v0.7.2, this is an issue with vim.fn.input
that was resolved in this upstream issue (requires nightly).
Yea I'm using v0.7.2
. Unfortunately I can't update to nightly for my work laptop :(
I've instead made a hacky workaround which seems to work so far.
M lua/nvim-surround/config.lua
@@ -276,8 +276,8 @@ M.default_opts = {
---@return string? @The user input.
M.get_input = function(prompt)
-- Since `vim.fn.input()` does not handle keyboard interrupts, we use a protected call to detect <C-c>
- local ok, result = pcall(vim.fn.input, { prompt = prompt, cancelreturn = vim.NIL })
- if ok and result ~= vim.NIL then
+ local ok, result = pcall(vim.fn.input, { prompt = prompt, cancelreturn = "\a" })
+ if ok and result ~= "\a" then
return result
end
end
Yeah sorry about that one. I was initially thinking of doing a workaround by using some arbitrarily long hash string to denote cancelreturn
, but then figured that I would just "do it right" once the patch was merged upstream. I'll leave this issue open and probably require v0.8 when the stable version drops, with limited support for 0.7+.
It seems that basically the same thing happens with function names.
With cursor at :`bar Input is:
ysiwf Result is:
null(bar)`
This is now fixed in nvim 0.8.
Yep, I'll close this issue once I update the README to require Neovim 0.8+
Checklist
main
branch?:h nvim-surround
to see if there might be any relevant information there?To reproduce
"a"
with cursor inside quotes.csqt<Esc>
which cancels prompt.Expected behavior
Text remains the same as
"a"
.Actual behavior
Text changed to
<null>a</null>
.Additional context
Same problem with
ysiwt<Esc>
.