1

Fix range jumps

This commit is contained in:
Alex Yatskov 2025-01-18 20:17:56 -08:00
parent 9737ef7f6b
commit 655663cb6f

View File

@ -34,19 +34,27 @@ local function find_closest()
end
end
local function find_at_cursor(start_cursor)
local function find_at_cursor(start_cursor, parent_range)
local pairing = Pairing.from_brace(start_cursor:get_value())
if pairing then
local cursor_current = Cursor:get_current()
start_cursor:set_current()
local stop_cursor = pairing:find_closest(true)
cursor_current:set_current()
if stop_cursor then
if not stop_cursor then
return
end
if parent_range and not parent_range:contains(stop_cursor) then
return
end
local range = Range.new(start_cursor, stop_cursor, pairing)
range:parse()
return range
end
end
end
function Range.new(start_cursor, stop_cursor, pairing)
@ -86,7 +94,7 @@ function Range:parse()
if cursor:is_string() or cursor:is_comment() then
append_param_value(Param.new_cursor_cell(cursor))
else
local range = find_at_cursor(cursor)
local range = find_at_cursor(cursor, self)
if range then
append_param_value(Param.new_range_cell(range))
cursor = range.stop_cursor