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