Skip to content

Commit

Permalink
feat: add output_panel.clear()
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelbeumer authored and Rónán Carrigan committed Oct 20, 2023
1 parent e8ed1ac commit 294d45d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lua/neotest/consumers/output_panel/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ local OutputPanel = require("neotest.consumers.output_panel.panel")
---@type neotest.OutputPanel
local panel

---@private
---@type number
local chan

local neotest = {}

---@toc_entry Output Panel Consumer
Expand All @@ -19,7 +23,6 @@ neotest.output_panel = {}
local init = function(client)
panel = OutputPanel(client)

local chan
---@param results table<string, neotest.Result>
client.listeners.results = function(adapter_id, results, partial)
if partial then
Expand Down Expand Up @@ -83,6 +86,16 @@ function neotest.output_panel.toggle()
end
end

--- Clears the output panel
--- >vim
--- lua require("neotest").output_panel.clear()
--- <
function neotest.output_panel.clear()
if chan then
vim.api.nvim_chan_send(chan, "\x1b[H\x1b[2J")
end
end

neotest.output_panel = setmetatable(neotest.output_panel, {
__call = function(_, client)
init(client)
Expand Down

0 comments on commit 294d45d

Please sign in to comment.