mirror of
https://github.com/ilyakooo0/nvim-autopairs.git
synced 2024-08-16 02:30:48 +03:00
fix: afterquote quote with out any text
This commit is contained in:
parent
e3e105b11a
commit
1df216ef70
@ -427,10 +427,12 @@ M.autopairs_afterquote = function(line, key_char)
|
||||
line = line or utils.text_get_current_line(0)
|
||||
local _, col = utils.get_cursor()
|
||||
local prev_char, next_char = utils.text_cusor_line(line, col + 1, 1, 1, false)
|
||||
local check_same = line:sub(col + 3, col + 3)
|
||||
if
|
||||
utils.is_bracket(prev_char)
|
||||
and utils.is_quote(next_char)
|
||||
and not utils.is_in_quote(line, col, next_char)
|
||||
and check_same ~= next_char
|
||||
then
|
||||
local is_prev_slash = false
|
||||
for i = #line - 2, #line, 1 do
|
||||
|
@ -22,8 +22,17 @@ local data = {
|
||||
filetype = 'lua',
|
||||
linenr = 5,
|
||||
key = [[(]],
|
||||
before = [[|"test" ]],
|
||||
after = [[(|"test") ]],
|
||||
before = [[|"test"]],
|
||||
after = [[(|"test")]],
|
||||
},
|
||||
{
|
||||
name = 'check quote without any text on end similar',
|
||||
filepath = './tests/endwise/init.lua',
|
||||
filetype = 'lua',
|
||||
linenr = 5,
|
||||
key = [[(]],
|
||||
before = [[ const [template, setTemplate] = useState|'')]],
|
||||
after = [[ const [template, setTemplate] = useState(|'')]],
|
||||
},
|
||||
|
||||
{
|
||||
@ -98,6 +107,6 @@ local run_data = _G.Test_filter(data)
|
||||
local _, ts_utils = pcall(require, 'nvim-treesitter.ts_utils')
|
||||
_G.TU = ts_utils
|
||||
|
||||
describe('[endwise tag]', function()
|
||||
describe('[afterquote tag]', function()
|
||||
_G.Test_withfile(run_data, {})
|
||||
end)
|
||||
|
@ -1,8 +1,7 @@
|
||||
local data1, data2
|
||||
local function wind()
|
||||
|
||||
|
||||
|
||||
vim.api.nvim_get_current_buf()
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user