mirror of
https://github.com/ilyakooo0/nvim-autopairs.git
synced 2024-10-26 08:41:46 +03:00
fix after quote with double character
This commit is contained in:
parent
93f8b9f0f5
commit
64c937940c
@ -417,21 +417,22 @@ M.autopairs_afterquote = function(line, key_char)
|
||||
local char = line:sub(i, i + #next_char - 1)
|
||||
local char_end = line:sub(i + 1, i + #next_char)
|
||||
if not is_prev_slash and char == next_char then
|
||||
if char_end ~= ',' then
|
||||
for _, rule in pairs(M.state.rules) do
|
||||
if rule.start_pair == prev_char and char_end ~= rule.end_pair then
|
||||
local new_text = line:sub(0, i)
|
||||
.. rule.end_pair
|
||||
.. line:sub(i + 1, #line)
|
||||
M.state.expr_quote = new_text
|
||||
local append = 'a'
|
||||
if col > 0 then
|
||||
append = 'la'
|
||||
end
|
||||
return utils.esc(
|
||||
'<esc><cmd>lua MPairs.autopairs_closequote_expr()<cr>' .. append
|
||||
)
|
||||
if char_end == ',' then
|
||||
return utils.esc(key_char)
|
||||
end
|
||||
for _, rule in pairs(M.state.rules) do
|
||||
if rule.start_pair == prev_char and char_end ~= rule.end_pair then
|
||||
local new_text = line:sub(0, i)
|
||||
.. rule.end_pair
|
||||
.. line:sub(i + 1, #line)
|
||||
M.state.expr_quote = new_text
|
||||
local append = 'a'
|
||||
if col > 0 then
|
||||
append = 'la'
|
||||
end
|
||||
return utils.esc(
|
||||
'<esc><cmd>lua MPairs.autopairs_closequote_expr()<cr>' .. append
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -81,6 +81,15 @@ local data = {
|
||||
before = [[|"data", abcdef]],
|
||||
after = [[(|"data", abcdef]],
|
||||
},
|
||||
{
|
||||
name = 'not add bracket with quote have comma',
|
||||
filepath = './tests/endwise/init.lua',
|
||||
filetype = 'lua',
|
||||
linenr = '5',
|
||||
key = [[(]],
|
||||
before = [[|"data", "abcdef"]],
|
||||
after = [[(|"data", "abcdef"]],
|
||||
},
|
||||
}
|
||||
|
||||
local run_data = _G.Test_filter(data)
|
||||
|
Loading…
Reference in New Issue
Block a user