(range) bounds check for TS caps
All checks were successful
NeoVim tests / code-quality (push) Successful in 1m33s

This commit is contained in:
Jonathan Apodaca 2025-08-09 08:59:32 -06:00
parent dcedd7c59b
commit bebefb601a

View File

@ -256,6 +256,9 @@ function Range.from_tsquery_caps(bufnr, query, opts)
Pos.new(bufnr, stop_row0 + 1, stop_col0 + 1),
'v'
)
if range.stop.lnum > vim.api.nvim_buf_line_count(bufnr) then
range.stop = range.stop:must_next(-1)
end
if not opts.contains_cursor or opts.contains_cursor and range:contains(cursor) then
local capture_name = q.captures[id]
if not ranges[capture_name] then ranges[capture_name] = {} end