From 43a07a028fcaae4f4e3e6c8dfbc1fbde818ea0a1 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Mon, 13 May 2024 12:54:05 -0500 Subject: [PATCH] fix: reparse source if the node has changes --- lua/nvim-ts-autotag/internal.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lua/nvim-ts-autotag/internal.lua b/lua/nvim-ts-autotag/internal.lua index aaa1404..3ce01bc 100644 --- a/lua/nvim-ts-autotag/internal.lua +++ b/lua/nvim-ts-autotag/internal.lua @@ -253,6 +253,13 @@ local function find_tag_node(opt) local name_tag_pattern = opt.name_tag_pattern local skip_tag_pattern = opt.skip_tag_pattern local find_child = opt.find_child or false + --- PERF: Some parsers don't seemingly pick up their trees correctly, so we have to reparse the + --- entire source. This is slow, see if we can avoid this. + if target and target:has_changes() then + local parser = vim.treesitter.get_parser() + _ = (parser and parser:parse(true) or nil) + target = ts_utils.get_node_at_cursor() + end local node if find_child then node = find_child_match({