mirror of
https://github.com/windwp/nvim-ts-autotag.git
synced 2025-01-01 12:49:15 -06:00
skip replace on special char < >
This commit is contained in:
parent
c404074515
commit
be64636cfb
@ -192,9 +192,6 @@ local function checkCloseTag()
|
||||
return false
|
||||
end
|
||||
|
||||
function M.code(cmd)
|
||||
return vim.api.nvim_replace_termcodes(cmd, true, false, true)
|
||||
end
|
||||
M.closeTag = function ()
|
||||
local result, tag_name = checkCloseTag()
|
||||
if result == true and tag_name ~= nil then
|
||||
@ -282,9 +279,22 @@ local function checkEndTag()
|
||||
end
|
||||
end
|
||||
|
||||
local function validate_rename()
|
||||
local cursor = vim.api.nvim_win_get_cursor('.')
|
||||
local line = vim.fn.getline(cursor[1])
|
||||
local char = line:sub(cursor[2] + 1, cursor[2] + 1)
|
||||
-- only rename when last character is a word
|
||||
if string.match(char,'%w') then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
M.renameTag = function ()
|
||||
checkStartTag()
|
||||
checkEndTag()
|
||||
if validate_rename() then
|
||||
checkStartTag()
|
||||
checkEndTag()
|
||||
end
|
||||
end
|
||||
|
||||
M.attach = function (bufnr)
|
||||
|
@ -17,7 +17,6 @@ set nocindent
|
||||
set nosmartindent
|
||||
set indentexpr=
|
||||
|
||||
TSUpdate
|
||||
|
||||
lua << EOF
|
||||
|
||||
|
@ -38,6 +38,15 @@ local data = {
|
||||
before = [[<di|v class="lla"> dsadsa </div> ]],
|
||||
after = [[<lala| class="lla"> dsadsa </lala|> ]]
|
||||
},
|
||||
{
|
||||
name = "html not rename close tag on char <" ,
|
||||
filepath = './sample/index.html',
|
||||
filetype = "html",
|
||||
linenr = 10,
|
||||
key = [[i<]],
|
||||
before = [[<div class="lla"> dsadsa |/button> ]],
|
||||
after = [[<div| class="lla"> dsadsa |</button> ]]
|
||||
},
|
||||
{
|
||||
name = "html rename close tag with attr" ,
|
||||
filepath = './sample/index.html',
|
||||
|
Loading…
Reference in New Issue
Block a user