mirror of
https://github.com/ilyakooo0/nvim-autopairs.git
synced 2024-10-03 19:17:32 +03:00
fix #295
This commit is contained in:
parent
5d75276fce
commit
99f6963392
@ -199,13 +199,16 @@ cond.is_bracket_line = function()
|
||||
---@param opts CondOpts
|
||||
return function(opts)
|
||||
log.debug('is_bracket_line')
|
||||
if utils.is_bracket(opts.char) and opts.next_char == opts.rule.end_pair then
|
||||
if utils.is_bracket(opts.char) and
|
||||
(opts.next_char == opts.rule.end_pair
|
||||
or opts.next_char == opts.rule.start_pair)
|
||||
then
|
||||
-- (( many char |)) => add
|
||||
-- ( many char |)) => not add
|
||||
local count_prev_char, count_next_char = count_bracket_char(
|
||||
opts.line,
|
||||
opts.char,
|
||||
opts.next_char
|
||||
opts.rule.start_pair,
|
||||
opts.rule.end_pair
|
||||
)
|
||||
if count_prev_char ~= count_next_char then
|
||||
return false
|
||||
|
@ -1,4 +1,3 @@
|
||||
local helpers = {}
|
||||
local npairs = require('nvim-autopairs')
|
||||
local Rule = require('nvim-autopairs.rule')
|
||||
local cond = require('nvim-autopairs.conds')
|
||||
@ -694,6 +693,18 @@ local data = {
|
||||
key = [[(]],
|
||||
before = [[ |`abcd`]],
|
||||
after = [[ (`abcd`) ]]
|
||||
},
|
||||
{
|
||||
name='should not add bracket on line have bracket ',
|
||||
key = [[(]],
|
||||
before = [[ |(abcd))]],
|
||||
after = [[ ((abcd)) ]]
|
||||
},
|
||||
{
|
||||
name='not add bracket on line have bracket ',
|
||||
key = [[(]],
|
||||
before = [[ |(abcd) ( visual)]],
|
||||
after = [[ ()(abcd) ( visual)]]
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user