Merge 220fe15d97ce0e3170f6fe662c0ae6532bd91953 into 26c365cc7d58d0da17b13e747855d331eb26fcf0

This commit is contained in:
Mike 2024-07-14 16:47:35 -05:00 committed by GitHub
commit 09748aca39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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