From 6b52c084531dd9831bb3f228c0d3a9f55fcf1565 Mon Sep 17 00:00:00 2001 From: Chen Asraf Date: Sun, 5 Apr 2026 13:13:38 +0300 Subject: [PATCH] fix: guard lang_tree:parse against upstream directive errors --- lua/treesitter-matchup/internal.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/treesitter-matchup/internal.lua b/lua/treesitter-matchup/internal.lua index 551418c..b8eb23e 100644 --- a/lua/treesitter-matchup/internal.lua +++ b/lua/treesitter-matchup/internal.lua @@ -147,7 +147,7 @@ M.get_matches = function(bufnr) local start_row = math.max(cursor[1] - stopline, 0) local end_row = math.min(cursor[1] + stopline, api.nvim_buf_line_count(bufnr)) - lang_tree:parse({ start_row, end_row }) + pcall(lang_tree.parse, lang_tree, { start_row, end_row }) ---@type vim.treesitter.LanguageTree? local nested_lang_tree = lang_tree:language_for_range({ cursor[1]-1, cursor[2], cursor[1]-1, cursor[2] }) while vim.tbl_isempty(matches) and nested_lang_tree ~= nil do