mirror of
https://github.com/windwp/nvim-ts-autotag.git
synced 2025-01-23 11:23:58 -06:00
Merge 7f9f55b285fa3893cd866e69ebec30f0a216dadf into 26c365cc7d58d0da17b13e747855d331eb26fcf0
This commit is contained in:
commit
487e24dd74
@ -63,7 +63,20 @@ end
|
||||
|
||||
M.get_node_text = function(node)
|
||||
local _, txt = pcall(get_node_text, node, vim.api.nvim_get_current_buf())
|
||||
return vim.split(txt, "\n") or {}
|
||||
|
||||
local texts = vim.split(txt, "\n")
|
||||
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
|
||||
|
||||
return filtered or {}
|
||||
end
|
||||
|
||||
-- Stolen from nvim `0.10.0` for `0.9.5` users
|
||||
|
Loading…
x
Reference in New Issue
Block a user