mirror of
https://github.com/ilyakooo0/nvim-autopairs.git
synced 2024-08-16 02:30:48 +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('next_char' .. next_char)
|
||||
if
|
||||
next_char == rule.end_pair
|
||||
and rule.is_regex == false
|
||||
utils.is_equal(rule.end_pair, next_char, rule.is_regex)
|
||||
and rule:can_move(cond_opt)
|
||||
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
|
||||
if
|
||||
utils.is_equal(rule.start_pair, prev_char, rule.is_regex)
|
||||
@ -281,8 +281,8 @@ M.autopairs_map = function(bufnr, char)
|
||||
then
|
||||
local end_pair = rule:get_end_pair(cond_opt)
|
||||
if add_char == 0 then char = "" end
|
||||
return utils.esc(
|
||||
char .. end_pair .. utils.repeat_key(utils.key.join_left, #end_pair))
|
||||
return utils.esc(char .. end_pair
|
||||
.. utils.repeat_key(utils.key.join_left, #end_pair))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -386,5 +386,30 @@ describe('autopairs ', function()
|
||||
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)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user