Skip to content

Commit 5e83dfb

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

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lua/nvim-treesitter-textobjects/shared.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ end
217217
---@return boolean
218218
local function is_in_range(range, row, col)
219219
local start_row, start_col, end_row, end_col = unpack(range) ---@type integer, integer, integer, integer
220-
end_col = end_col - 1
220+
-- end_col = end_col - 1 -- this is the line that causes the problem, but maybe it has to be like that in other contexts?
221221

222222
local is_in_rows = start_row <= row and end_row >= row
223223
local is_after_start_col_if_needed = true
@@ -231,6 +231,16 @@ local function is_in_range(range, row, col)
231231
return is_in_rows and is_after_start_col_if_needed and is_before_end_col_if_needed
232232
end
233233

234+
-- alternatively don't use is_in_range(), instead use this 80IQ implementation of contains() which works
235+
-- ---@param range_outer Range4
236+
-- ---@param range_inner Range4
237+
-- ---@return boolean
238+
-- local function contains(range_outer, range_inner)
239+
-- local start_row_o, start_col_o, end_row_o, end_col_o = unpack(range_outer)
240+
-- local start_row_i, start_col_i, end_row_i, end_col_i = unpack(range_inner)
241+
-- return start_row_o <= start_row_i and start_col_o <= start_col_i and end_row_o >= end_row_i and end_col_o >= end_col_i
242+
-- end
243+
234244
---@param range1 Range4
235245
---@param range2 Range4
236246
---@return boolean

0 commit comments

Comments
 (0)