Skip to content

Commit 6f424e0

Browse files
committed
fix(output_window): clear all extmarks when clearing
I've seen RenderMarkdown leave some extmarks behind so force clear extmarks in all domains when clearing the output window.
1 parent f921ce8 commit 6f424e0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lua/opencode/ui/output_window.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,16 @@ end
9494
---Clear output buf extmarks
9595
---@param start_line? integer Line to start clearing, defaults 0
9696
---@param end_line? integer Line to clear until, defaults to -1
97-
function M.clear_extmarks(start_line, end_line)
97+
---@param clear_all? boolean If true, clears all extmarks in the buffer
98+
function M.clear_extmarks(start_line, end_line, clear_all)
9899
if not M.mounted() or not state.windows.output_buf then
99100
return
100101
end
101102

102103
start_line = start_line or 0
103104
end_line = end_line or -1
104105

105-
vim.api.nvim_buf_clear_namespace(state.windows.output_buf, M.namespace, start_line, end_line)
106+
vim.api.nvim_buf_clear_namespace(state.windows.output_buf, clear_all and -1 or M.namespace, start_line, end_line)
106107
end
107108

108109
---Apply extmarks to the output buffer
@@ -181,7 +182,9 @@ end
181182

182183
function M.clear()
183184
M.set_lines({})
184-
M.clear_extmarks()
185+
-- clear extmarks in all namespaces as I've seen RenderMarkdown leave some
186+
-- extmarks behind
187+
M.clear_extmarks(0, -1, true)
185188
end
186189

187190
return M

0 commit comments

Comments
 (0)