From bb65adf1df1735c65d6fbc627a0e949218d0cb4e Mon Sep 17 00:00:00 2001 From: Pierre-Nicolas Watin-Augouard Date: Mon, 2 Dec 2024 12:21:00 +0100 Subject: [PATCH 1/2] fix: break out of infinite loop when node:parent() is detected --- lua/nvim-ts-autotag/internal.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/nvim-ts-autotag/internal.lua b/lua/nvim-ts-autotag/internal.lua index b816b93..8d0dc7e 100644 --- a/lua/nvim-ts-autotag/internal.lua +++ b/lua/nvim-ts-autotag/internal.lua @@ -44,7 +44,12 @@ local function is_in_template_tag() local has_template_string = false local current_node = cursor_node + local visited_nodes = {} while not (has_element and has_template_string) and current_node do + if visited_nodes[node_id] then + break + end + visited_nodes[node_id] = true if not has_element and current_node:type() == "element" then has_element = true end From e451e0c6ebdf59f34342c6b7f8f5dc72dfc8c8f1 Mon Sep 17 00:00:00 2001 From: Pierre-Nicolas Watin-Augouard <82295737+pnwatin@users.noreply.github.com> Date: Mon, 2 Dec 2024 19:25:04 +0100 Subject: [PATCH 2/2] fix: add missing node_id Co-authored-by: Price Hiller --- lua/nvim-ts-autotag/internal.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/nvim-ts-autotag/internal.lua b/lua/nvim-ts-autotag/internal.lua index 8d0dc7e..807bc18 100644 --- a/lua/nvim-ts-autotag/internal.lua +++ b/lua/nvim-ts-autotag/internal.lua @@ -46,6 +46,7 @@ local function is_in_template_tag() local current_node = cursor_node local visited_nodes = {} while not (has_element and has_template_string) and current_node do + local node_id = current_node:id() if visited_nodes[node_id] then break end