Closed apettel closed 1 year ago
If you're using the tagged version of the plugin, please try the untagged version. If you're already on the untagged version, try updating the plugin. Are you able to replicate this with a minimal configuration?
I'm using the current version:
● nvim-surround 1.2ms start
dir /Users/ap/.local/share/nvim/lazy/nvim-surround
url https://github.com/kylechui/nvim-surround
branch main
commit 8680311
readme README.md
help |nvim-surround.txt|
This little patch fixed it for me (with the cs command still working):
diff --git a/lua/nvim-surround/utils.lua b/lua/nvim-surround/utils.lua
index 7f90a1d..4418e0c 100644
--- a/lua/nvim-surround/utils.lua
+++ b/lua/nvim-surround/utils.lua
@@ -16,6 +16,9 @@ M.get_nearest_selections = function(char, action)
char = config.get_alias(char)
local chars = functional.to_list(config.get_opts().aliases[char] or char)
+ if not chars then
+ return
+ end
local curpos = buffer.get_curpos()
local selections_list = {}
-- Iterate through all possible selections for each aliased character, and find the closest pair
If nil is an ok return value for this function, then this fix might be ok.
You are correct, that function does potentially return nil
. I'm not sure why the type system didn't catch that.
Hi there, I've just fixed the issue and added a few test cases to guard against this bug. Please update the plugin and let me know if it's been fixed.
The problem is fixed. Thank you, great work!
When I type cs[Esc] I get the following error:
E5108: Error executing lua ...hare/nvim/lazy/nvim-surround/lua/nvim-surround/utils.lua:22: bad argument #1 to 'ipairs' (table expected, got nil) stack traceback: [C]: in function 'ipairs' ...hare/nvim/lazy/nvim-surround/lua/nvim-surround/utils.lua:22: in function 'get_nearest_selections' ...share/nvim/lazy/nvim-surround/lua/nvim-surround/init.lua:280: in function <...share/nvim/lazy/nvim-surround/lua/nvim-surround/init.lua:274>