mirror of
https://github.com/ilyakooo0/nvim-autopairs.git
synced 2024-09-11 07:15:44 +03:00
disable add bracket after quote with comma
This commit is contained in:
parent
4b4ac6099d
commit
b09ab7495e
@ -415,16 +415,24 @@ M.autopairs_afterquote = function(line, key_char)
|
||||
then
|
||||
local is_prev_slash = false
|
||||
for i = col + 2 + #next_char, #line, 1 do
|
||||
local char = line:sub(i, i + #next_char -1)
|
||||
local char_end = line:sub(i + 1, i + #next_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)
|
||||
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)
|
||||
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
|
||||
end
|
||||
|
@ -64,7 +64,6 @@ local data = {
|
||||
},
|
||||
|
||||
{
|
||||
-- only=true,
|
||||
name = 'test add close quote inside string',
|
||||
filepath = './tests/endwise/init.lua',
|
||||
filetype = 'lua',
|
||||
@ -73,6 +72,15 @@ local data = {
|
||||
before = [[const abc="visu|"dsa"" ]],
|
||||
after = [[const abc="visu(|"dsa"" ]],
|
||||
},
|
||||
{
|
||||
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