aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-treesitter/tsrange.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/lua/nvim-treesitter/tsrange.lua b/lua/nvim-treesitter/tsrange.lua
index b215189f1..b8205c4b6 100644
--- a/lua/nvim-treesitter/tsrange.lua
+++ b/lua/nvim-treesitter/tsrange.lua
@@ -26,8 +26,8 @@ end
function TSRange.from_nodes(buf, start_node, end_node)
TSRange.__index = TSRange
- local start_pos = {start_node:start()}
- local end_pos = {end_node:end_()}
+ local start_pos = start_node and {start_node:start()} or {end_node:start()}
+ local end_pos = end_node and {end_node:end_()} or {start_node:end_()}
return setmetatable(
{
start_pos = {start_pos[1], start_pos[2], start_pos[3]},