mirror of
https://github.com/ilyakooo0/nvim-autopairs.git
synced 2024-09-11 07:15:44 +03:00
fix move right multi character
This commit is contained in:
parent
b09ab7495e
commit
de252fadc3
@ -269,11 +269,11 @@ M.autopairs_map = function(bufnr, char)
|
|||||||
-- log.debug('prev_char' .. prev_char)
|
-- log.debug('prev_char' .. prev_char)
|
||||||
-- log.debug('next_char' .. next_char)
|
-- log.debug('next_char' .. next_char)
|
||||||
if
|
if
|
||||||
next_char == rule.end_pair
|
utils.is_equal(rule.end_pair, next_char, rule.is_regex)
|
||||||
and rule.is_regex == false
|
|
||||||
and rule:can_move(cond_opt)
|
and rule:can_move(cond_opt)
|
||||||
then
|
then
|
||||||
return utils.esc(utils.key.join_right)
|
local end_pair = rule:get_end_pair(cond_opt)
|
||||||
|
return utils.esc(utils.repeat_key(utils.key.join_right, #end_pair))
|
||||||
end
|
end
|
||||||
if
|
if
|
||||||
utils.is_equal(rule.start_pair, prev_char, rule.is_regex)
|
utils.is_equal(rule.start_pair, prev_char, rule.is_regex)
|
||||||
@ -281,8 +281,8 @@ M.autopairs_map = function(bufnr, char)
|
|||||||
then
|
then
|
||||||
local end_pair = rule:get_end_pair(cond_opt)
|
local end_pair = rule:get_end_pair(cond_opt)
|
||||||
if add_char == 0 then char = "" end
|
if add_char == 0 then char = "" end
|
||||||
return utils.esc(
|
return utils.esc(char .. end_pair
|
||||||
char .. end_pair .. utils.repeat_key(utils.key.join_left, #end_pair))
|
.. utils.repeat_key(utils.key.join_left, #end_pair))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -386,5 +386,30 @@ describe('autopairs ', function()
|
|||||||
after = [[((|)))) ]],
|
after = [[((|)))) ]],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Test(run_data)
|
||||||
|
|
||||||
|
npairs.setup({})
|
||||||
|
npairs.add_rules {
|
||||||
|
Rule(' ', ' '):with_pair(function(opts)
|
||||||
|
local pair = opts.line:sub(opts.col, opts.col + 1)
|
||||||
|
return vim.tbl_contains({'()', '[]', '{}'}, pair)
|
||||||
|
end),
|
||||||
|
Rule('( ',' )')
|
||||||
|
:with_pair(function() return false end)
|
||||||
|
:with_del(function() return false end)
|
||||||
|
:with_move(function() return true end)
|
||||||
|
:use_regex(false,")")
|
||||||
|
}
|
||||||
|
run_data={
|
||||||
|
{
|
||||||
|
name = "test disable check bracket line" ,
|
||||||
|
filetype = "latex",
|
||||||
|
key = [[)]],
|
||||||
|
before = [[( | ) ]],
|
||||||
|
after = [[( )| ]],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
Test(run_data)
|
Test(run_data)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user