Skip to content

Commit 81e3dc9

Browse files
committed
chore(output_window): debug perf tracking
Remove when perf issue resolved
1 parent a9af2b4 commit 81e3dc9

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

lua/opencode/ui/output_window.lua

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ function M.get_buf_line_count()
6969
return vim.api.nvim_buf_line_count(state.windows.output_buf)
7070
end
7171

72+
--- FIXME: remove debugging code
73+
M._lines_set = 0
74+
M._set_calls = 0
75+
7276
---Set the output buffer contents
7377
---@param lines string[] The lines to set
7478
---@param start_line? integer The starting line to set, defaults to 0
@@ -86,14 +90,45 @@ function M.set_lines(lines, start_line, end_line)
8690
return
8791
end
8892

93+
--- FIXME: remove debugging code
94+
if vim.tbl_isempty(lines) then
95+
M._lines_set = 0
96+
M._set_calls = 0
97+
else
98+
M._lines_set = M._lines_set + #lines
99+
M._set_calls = M._set_calls + 1
100+
end
101+
89102
vim.api.nvim_set_option_value('modifiable', true, { buf = windows.output_buf })
103+
-- vim.notify(vim.inspect(lines))
90104
vim.api.nvim_buf_set_lines(windows.output_buf, start_line, end_line, false, lines)
91105
vim.api.nvim_set_option_value('modifiable', false, { buf = windows.output_buf })
92106
end
93107

108+
--- FIXME: remove debugging code
109+
---Set text in a specific line at character positions
110+
---@param line integer The line number (0-indexed)
111+
---@param start_col integer The starting column (0-indexed)
112+
---@param end_col integer The ending column (0-indexed)
113+
---@param text string The text to insert
114+
function M.set_text(line, start_col, end_col, text)
115+
if not M.mounted() then
116+
return
117+
end
118+
119+
local windows = state.windows
120+
if not windows or not windows.output_buf then
121+
return
122+
end
123+
124+
vim.api.nvim_set_option_value('modifiable', true, { buf = windows.output_buf })
125+
vim.api.nvim_buf_set_text(windows.output_buf, line, start_col, line, end_col, { text })
126+
vim.api.nvim_set_option_value('modifiable', false, { buf = windows.output_buf })
127+
end
128+
94129
---Clear output buf extmarks
95130
---@param start_line? integer Line to start clearing, defaults 0
96-
---@param end_line? integer Line to to clear until, defaults to -1
131+
---@param end_line? integer Line to clear until, defaults to -1
97132
function M.clear_extmarks(start_line, end_line)
98133
if not M.mounted() or not state.windows.output_buf then
99134
return

tests/manual/renderer_replay.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,21 @@ function M.emit_event(event)
7575
or event.properties.partID
7676
or event.properties.messageID
7777
or ''
78-
vim.notify('Event ' .. index .. '/' .. count .. ': ' .. event.type .. ' ' .. id .. '', vim.log.levels.INFO)
78+
vim.notify(
79+
'Event '
80+
.. index
81+
.. '/'
82+
.. count
83+
.. ': '
84+
.. event.type
85+
.. ' '
86+
.. id
87+
.. ' lines_set: '
88+
.. output_window._lines_set
89+
.. ' set_calls: '
90+
.. output_window._set_calls,
91+
vim.log.levels.INFO
92+
)
7993
helpers.replay_event(event)
8094
end)
8195
end

0 commit comments

Comments
 (0)