1
This commit is contained in:
Alex Yatskov 2025-01-18 19:11:04 -08:00
parent 711e800226
commit 726577ee00
2 changed files with 29 additions and 16 deletions

View File

@ -12,11 +12,17 @@ end
function ParamCursorCell:hit_test(cursor)
if self.cursor == cursor then
return {}
return {{
type = 'cursor_cell',
value = self.cursor:get_value(),
}}
end
end
function ParamCursorCell:hit_search()
function ParamCursorCell:hit_search(trace, depth)
local frame = trace[depth]
assert(frame.type == 'cursor_cell')
return self.cursor
end
@ -32,10 +38,6 @@ function ParamCursorCell:is_empty()
return not self.cursor:get_value():match('%S')
end
function ParamCursorCell:get_type()
return 'cursor'
end
local ParamRangeCell = {}
ParamRangeCell.__index = ParamRangeCell
@ -49,11 +51,18 @@ function ParamRangeCell:write(builder, wrapped)
end
function ParamRangeCell:hit_test(cursor)
return self.range:hit_test(cursor)
local trace = self.range:hit_test(cursor)
if trace then
table.insert(trace, 1, {type = 'range_cell'})
return trace
end
end
function ParamRangeCell:hit_search(trace, depth)
return self.range:hit_search(trace, depth)
local frame = trace[depth]
assert(frame.type == 'range_cell')
return self.range:hit_search(trace, depth + 1)
end
function ParamRangeCell:get_start_row()
@ -68,10 +77,6 @@ function ParamRangeCell:is_empty()
return false
end
function ParamRangeCell:get_type()
return 'range'
end
local Param = {}
Param.__index = Param
@ -108,7 +113,6 @@ function Param:hit_test(cursor)
table.insert(trace, 1, {
index = i,
length = #self.cells,
subtype = cell:get_type(),
type = 'param_cell',
})
@ -119,6 +123,10 @@ end
function Param:hit_search(trace, depth)
local frame = trace[depth]
assert(frame.index <= #self.cells)
assert(frame.length == #self.cells)
assert(frame.type == 'param_cell')
return self.cells[frame.index]:hit_search(trace, depth + 1)
end

View File

@ -111,8 +111,8 @@ function Range:hit_test(cursor)
table.insert(trace, 1, {
index = i,
length = #self.params,
subtype = self.pairing.open,
type = 'range_param',
value = self.pairing.open,
})
return trace
@ -122,14 +122,19 @@ function Range:hit_test(cursor)
return {
index = 0,
length = #self.params,
subtype = self.pairing.open,
type = 'range_padding',
value = self.pairing.open,
}
end
end
function Range:hit_search(trace, depth)
local frame = trace[depth]
assert(frame.index <= #self.params)
assert(frame.length == #self.params)
assert(frame.type == 'range_param')
assert(frame.value == self.pairing.open)
if frame.index == 0 then
return self.start_cursor
else