From 1849f30bb5d7f78ad0c3b129456917f170e4acf4 Mon Sep 17 00:00:00 2001 From: Thomas Vigouroux Date: Wed, 15 Jul 2020 09:29:12 +0200 Subject: fix(ts_utils): be sure to parse to get root Be sure to call `parser:parser()` to get a tree instead of getting the tree directly. This will not cost anything is the buffer is freshly parsed. Fixes #181 --- lua/nvim-treesitter/ts_utils.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/nvim-treesitter/ts_utils.lua b/lua/nvim-treesitter/ts_utils.lua index ebeb12354..0882155c4 100644 --- a/lua/nvim-treesitter/ts_utils.lua +++ b/lua/nvim-treesitter/ts_utils.lua @@ -210,7 +210,7 @@ end function M.get_node_at_cursor(winnr) local cursor = api.nvim_win_get_cursor(winnr or 0) - local root = parsers.get_parser().tree:root() + local root = parsers.get_parser():parse():root() return root:named_descendant_for_range(cursor[1]-1,cursor[2],cursor[1]-1,cursor[2]) end -- cgit v1.2.3-70-g09d2