refractor(parser): get_details: Use flattened_outline_items
This commit is contained in:
@@ -32,7 +32,8 @@ end
|
||||
|
||||
local function setup_buffer_autocmd()
|
||||
if config.options.auto_preview then
|
||||
vim.cmd("au CursorHold <buffer> lua require'symbols-outline.preview'.show()")
|
||||
vim.cmd(
|
||||
"au CursorHold <buffer> lua require'symbols-outline.preview'.show()")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -67,8 +68,7 @@ function M._refresh()
|
||||
M.state.flattened_outline_items =
|
||||
parser.flatten(parser.parse(result))
|
||||
|
||||
writer.parse_and_write(M.state.outline_buf, M.state.outline_win,
|
||||
M.state.outline_items,
|
||||
writer.parse_and_write(M.state.outline_buf,
|
||||
M.state.flattened_outline_items)
|
||||
end)
|
||||
end
|
||||
@@ -203,9 +203,7 @@ local function handler(_, _, result, client_id)
|
||||
M.state.outline_items = parser.parse(result)
|
||||
M.state.flattened_outline_items = parser.flatten(parser.parse(result))
|
||||
|
||||
writer.parse_and_write(M.state.outline_buf, M.state.outline_win,
|
||||
M.state.outline_items,
|
||||
M.state.flattened_outline_items)
|
||||
writer.parse_and_write(M.state.outline_buf, M.state.flattened_outline_items)
|
||||
ui.setup_highlights()
|
||||
end
|
||||
|
||||
|
||||
@@ -119,14 +119,10 @@ function M.get_lines(flattened_outline_items)
|
||||
return lines
|
||||
end
|
||||
|
||||
function M.get_details(outline_items, bufnr, winnr, lines)
|
||||
lines = lines or {}
|
||||
for _, value in ipairs(outline_items) do
|
||||
function M.get_details(flattened_outline_items)
|
||||
local lines = {}
|
||||
for _, value in ipairs(flattened_outline_items) do
|
||||
table.insert(lines, value.detail or "")
|
||||
|
||||
if value.children ~= nil then
|
||||
M.get_details(value.children, bufnr, winnr, lines)
|
||||
end
|
||||
end
|
||||
return lines
|
||||
end
|
||||
|
||||
@@ -32,12 +32,12 @@ end
|
||||
|
||||
-- runs the whole writing routine where the text is cleared, new data is parsed
|
||||
-- and then written
|
||||
function M.parse_and_write(bufnr, winnr, outline_items, flattened_outline_items)
|
||||
function M.parse_and_write(bufnr, flattened_outline_items)
|
||||
local lines = parser.get_lines(flattened_outline_items)
|
||||
M.write_outline(bufnr, lines)
|
||||
|
||||
clear_virt_text(bufnr)
|
||||
local details = parser.get_details(outline_items, bufnr, winnr)
|
||||
local details = parser.get_details(flattened_outline_items)
|
||||
M.write_details(bufnr, details)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user