mirror of
https://github.com/ilyakooo0/nvim-autopairs.git
synced 2024-09-11 07:15:44 +03:00
fix #204
This commit is contained in:
parent
5348e4a778
commit
c027bbb7eb
@ -165,10 +165,9 @@ cond.is_bracket_line = function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
cond.inside_quote = function()
|
cond.inside_quote = function()
|
||||||
return function(opts)
|
return function(opts)
|
||||||
log.debug('inside_quote')
|
log.debug('inside_quote')
|
||||||
return utils.is_in_quotes(opts.text, opts.col - 1)
|
return utils.is_in_quotes(opts.text, opts.col - 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -45,12 +45,12 @@ end
|
|||||||
---check cursor is inside a quote
|
---check cursor is inside a quote
|
||||||
---@param line string
|
---@param line string
|
||||||
---@param pos number positin in line
|
---@param pos number positin in line
|
||||||
---@param quote nil|string specify a quote string
|
---@param quote_type nil|string specify a quote
|
||||||
---@return boolean
|
---@return boolean
|
||||||
M.is_in_quotes = function (line, pos, quote)
|
M.is_in_quotes = function (line, pos, quote_type)
|
||||||
local cIndex = 0
|
local cIndex = 0
|
||||||
local result = false
|
local result = false
|
||||||
local last_char = quote or ''
|
local last_char = quote_type or ''
|
||||||
|
|
||||||
while cIndex < string.len(line) and cIndex < pos do
|
while cIndex < string.len(line) and cIndex < pos do
|
||||||
cIndex = cIndex + 1
|
cIndex = cIndex + 1
|
||||||
@ -61,9 +61,11 @@ M.is_in_quotes = function (line, pos, quote)
|
|||||||
line:sub(cIndex -1, cIndex -1) ~= "\\"
|
line:sub(cIndex -1, cIndex -1) ~= "\\"
|
||||||
then
|
then
|
||||||
result = false
|
result = false
|
||||||
last_char = quote or ''
|
last_char = quote_type or ''
|
||||||
elseif result == false and M.is_quote(char) then
|
elseif result == false and M.is_quote(char)
|
||||||
last_char = quote or char
|
and (not quote_type or char == quote_type)
|
||||||
|
then
|
||||||
|
last_char = quote_type or char
|
||||||
result = true
|
result = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -162,19 +162,11 @@ local data = {
|
|||||||
after = [[("abcd\""|)]]
|
after = [[("abcd\""|)]]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "move right on close bracket",
|
filetype = 'rust',
|
||||||
filetype="javascript",
|
name = 'move right double quote after single quote',
|
||||||
key = [[)]],
|
key = [["]],
|
||||||
before = [[("(dsadsa|" gs})]],
|
before = [[ ('x').expect("|");]],
|
||||||
after = [[("(dsadsa)|" gs})]]
|
after = [[ ('x').expect(""|);]],
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name = "move right when inside single quote with special slash",
|
|
||||||
filetype="javascript",
|
|
||||||
key = [[']],
|
|
||||||
before = [[nvim_set_var('test_thing|')]],
|
|
||||||
after = [[nvim_set_var('test_thing'|)]]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "delete bracket",
|
name = "delete bracket",
|
||||||
@ -587,6 +579,7 @@ describe('autopairs ', function()
|
|||||||
if value.setup_func then
|
if value.setup_func then
|
||||||
value.setup_func()
|
value.setup_func()
|
||||||
end
|
end
|
||||||
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user