Skip to content

Commit 9a165ce

Browse files
committed
fix @parameter.inner scoping issues
Fixes #832
1 parent 0d7c800 commit 9a165ce

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lua/nvim-treesitter-textobjects/shared.lua

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ function M.find_best_range(bufnr, capture_string, query_group, filter_predicate,
211211
return best
212212
end
213213

214+
-- TODO: replace with `vim.Range:has(vim.Pos)` when we drop support for nvim 0.11
214215
---@param range Range4
215216
---@param row integer
216217
---@param col integer
@@ -231,11 +232,18 @@ local function is_in_range(range, row, col)
231232
return is_in_rows and is_after_start_col_if_needed and is_before_end_col_if_needed
232233
end
233234

234-
---@param range1 Range4
235-
---@param range2 Range4
235+
-- TODO: replace with `vim.Range:has(vim.Range)` when we drop support for 0.11
236+
---@param outer Range4
237+
---@param inner Range4
236238
---@return boolean
237-
local function contains(range1, range2)
238-
return is_in_range(range1, range2[1], range2[2]) and is_in_range(range1, range2[3], range2[4])
239+
local function contains(outer, inner)
240+
local start_row_o, start_col_o, end_row_o, end_col_o = unpack(outer)
241+
local start_row_i, start_col_i, end_row_i, end_col_i = unpack(inner)
242+
243+
return start_row_o <= start_row_i
244+
and start_col_o <= start_col_i
245+
and end_row_o >= end_row_i
246+
and end_col_o >= end_col_i
239247
end
240248

241249
---@param range Range6

0 commit comments

Comments
 (0)