mirror of
https://github.com/windwp/nvim-ts-autotag.git
synced 2025-01-23 13:43:54 -06:00
Compare commits
2 Commits
487e24dd74
...
09748aca39
Author | SHA1 | Date | |
---|---|---|---|
|
09748aca39 | ||
|
220fe15d97 |
@ -287,8 +287,20 @@ local function validate_tag_regex(node, start_regex, end_regex)
|
||||
if node == nil then
|
||||
return false
|
||||
end
|
||||
|
||||
local texts = utils.get_node_text(node)
|
||||
if string.match(texts[1], start_regex) and string.match(texts[#texts], end_regex) then
|
||||
local filtered = {}
|
||||
|
||||
-- For some nodes (tsx) 'vim.treesitter.get_node_text' can return empty lines or lines with spaces
|
||||
-- We have to exclude them
|
||||
for i = 1, #texts do
|
||||
local text = texts[i]:gsub("^%s*(.-)%s*$", "%1")
|
||||
if text ~= "" then
|
||||
filtered[#filtered + 1] = text
|
||||
end
|
||||
end
|
||||
|
||||
if string.match(filtered[1], start_regex) and string.match(filtered[#filtered], end_regex) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
|
Loading…
x
Reference in New Issue
Block a user