Skip to content

Commit

Permalink
Fix brace pair edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
mgnsk committed Jul 10, 2024
1 parent 0a8a23d commit 3c74f68
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lua/dumb-autopairs/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function M.setup(config)

if right == "" then
feedkeys(pair.left .. pair.right .. "<Left>")
elseif has_open_brace_suffix(left) and has_close_brace_prefix(right) then
elseif has_open_brace_suffix(left) or has_close_brace_prefix(right) then
feedkeys(pair.left .. pair.right .. "<Left>")
else
feedkeys(pair.left)
Expand Down
4 changes: 2 additions & 2 deletions tests/braces_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ local data = {
after = { [[{}|]] },
},
{
name = "no pair when existing brace on right",
name = "pair when existing brace on right",
before = [[| }]],
feed = [[i{]],
after = { [[{| }]] },
after = { [[{|} }]] },
},
{
name = "no pair when word on right",
Expand Down

0 comments on commit 3c74f68

Please sign in to comment.