fix: Don't auto tag fragment if not in jsx (#210)

This commit is contained in:
Angel Kozlev 2024-08-15 01:12:53 +01:00 committed by GitHub
parent dc5e1687ab
commit 0cb76eea80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 0 deletions

View File

@ -37,6 +37,13 @@ end
---@return boolean
function M.is_react_fragment()
local node = vim.treesitter.get_node()
-- Bail out if the treesitter doesn't recognize `<>` as jsx_opening_element
if not node or node:type() ~= "jsx_opening_element" then
return false
end
local line = vim.fn.getline(".")
local col = vim.fn.col(".") - 2
local strpart = vim.fn.strpart(line, col)

View File

@ -255,6 +255,15 @@ local data = {
before = [[<input| ]],
after = [[<input>| ]],
},
{
name = "28 typescriptreact not close fragment in generic argument delimeters",
filepath = "./sample/index.tsx",
filetype = "typescriptreact",
linenr = 1,
key = [[>]],
before = [[type Foo = Bar<| ]],
after = [[type Foo = Bar<>]],
},
}
local autotag = require("nvim-ts-autotag")