Skip to content

Commit

Permalink
feat(output_panel): clear entire buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
Rónán Carrigan committed Oct 20, 2023
1 parent 294d45d commit 71e5b37
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 8 additions & 0 deletions doc/neotest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,14 @@ Toggle the output panel
lua require("neotest").output_panel.toggle()
<

*neotest.output_panel.clear()*
`clear`()

Clears the output panel
>vim
lua require("neotest").output_panel.clear()
<


==============================================================================
neotest.run *neotest.run*
Expand Down
11 changes: 4 additions & 7 deletions lua/neotest/consumers/output_panel/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ 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 @@ -23,6 +19,7 @@ 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 @@ -91,9 +88,9 @@ end
--- 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
nio.api.nvim_buf_set_option(panel.win:buffer(), "modifiable", true)
nio.api.nvim_buf_set_lines(panel.win:buffer(), 0, -1, false, {})
nio.api.nvim_buf_set_option(panel.win:buffer(), "modifiable", false)
end

neotest.output_panel = setmetatable(neotest.output_panel, {
Expand Down

0 comments on commit 71e5b37

Please sign in to comment.