Add debug info
This commit is contained in:
parent
6ebe65a9e4
commit
711e800226
@ -38,7 +38,21 @@ local function reflow()
|
||||
return true
|
||||
end
|
||||
|
||||
local function inspect()
|
||||
local range = Range.find_closest()
|
||||
if range then
|
||||
local trace = range:hit_test(Cursor.get_current())
|
||||
assert(trace)
|
||||
print('--- range start ---')
|
||||
dump(trace)
|
||||
print('--- range stop ---')
|
||||
else
|
||||
print('no range found!')
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
inspect = inspect,
|
||||
reflow = reflow,
|
||||
setup = Options.setup,
|
||||
}
|
||||
|
@ -32,6 +32,10 @@ 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,7 +53,7 @@ function ParamRangeCell:hit_test(cursor)
|
||||
end
|
||||
|
||||
function ParamRangeCell:hit_search(trace, depth)
|
||||
return self.range:hit_search(trace, depth + 1)
|
||||
return self.range:hit_search(trace, depth)
|
||||
end
|
||||
|
||||
function ParamRangeCell:get_start_row()
|
||||
@ -64,6 +68,10 @@ function ParamRangeCell:is_empty()
|
||||
return false
|
||||
end
|
||||
|
||||
function ParamRangeCell:get_type()
|
||||
return 'range'
|
||||
end
|
||||
|
||||
local Param = {}
|
||||
Param.__index = Param
|
||||
|
||||
@ -97,15 +105,21 @@ function Param:hit_test(cursor)
|
||||
for i, cell in ipairs(self.cells) do
|
||||
local trace = cell:hit_test(cursor)
|
||||
if trace then
|
||||
table.insert(trace, 1, i)
|
||||
table.insert(trace, 1, {
|
||||
index = i,
|
||||
length = #self.cells,
|
||||
subtype = cell:get_type(),
|
||||
type='param_cell',
|
||||
})
|
||||
|
||||
return trace
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Param:hit_search(trace, depth)
|
||||
local index = trace[depth]
|
||||
return self.cells[index]:hit_search(trace, depth)
|
||||
local frame = trace[depth]
|
||||
return self.cells[frame.index]:hit_search(trace, depth + 1)
|
||||
end
|
||||
|
||||
function Param:write(builder, wrapped)
|
||||
|
@ -105,32 +105,35 @@ end
|
||||
|
||||
function Range:hit_test(cursor)
|
||||
if self:contains(cursor) then
|
||||
local trace = nil
|
||||
for i, param in pairs(self.params) do
|
||||
local trace_param = param:hit_test(cursor)
|
||||
if trace_param then
|
||||
trace = {i}
|
||||
for _, trace_param_frame in ipairs(trace_param) do
|
||||
table.insert(trace, trace_param_frame)
|
||||
end
|
||||
break
|
||||
local trace = param:hit_test(cursor)
|
||||
if trace then
|
||||
table.insert(trace, 1, {
|
||||
index = i,
|
||||
length = #self.params,
|
||||
subtype = self.pairing.open,
|
||||
type = 'range_param',
|
||||
})
|
||||
|
||||
return trace
|
||||
end
|
||||
end
|
||||
|
||||
if not trace then
|
||||
trace = {0}
|
||||
end
|
||||
|
||||
return trace
|
||||
return {
|
||||
index = 0,
|
||||
length = #self.params,
|
||||
subtype = self.pairing.open,
|
||||
type = 'range_padding',
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function Range:hit_search(trace, depth)
|
||||
local index = trace[depth]
|
||||
if index == 0 then
|
||||
local frame = trace[depth]
|
||||
if frame.index == 0 then
|
||||
return self.start_cursor
|
||||
else
|
||||
return self.params[index]:hit_search(trace, depth + 1)
|
||||
return self.params[frame.index]:hit_search(trace, depth + 1)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -8,11 +8,18 @@ if not vim.g.argonaut_loaded then
|
||||
end
|
||||
|
||||
local function argonaut_reflow()
|
||||
argonaut_reload()
|
||||
require('argonaut').reflow()
|
||||
end
|
||||
|
||||
local function argonaut_inspect()
|
||||
argonaut_reload()
|
||||
require('argonaut').inspect()
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command('ArgonautReload', argonaut_reload, {})
|
||||
vim.api.nvim_create_user_command('ArgonautReflow', argonaut_reflow, {})
|
||||
vim.api.nvim_create_user_command('ArgonautInspect', argonaut_inspect, {})
|
||||
|
||||
vim.g.argonaut_loaded = true
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user