From 71e5b37dba5ca4514bd6d3e21e5efe60a62ddceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3n=C3=A1n=20Carrigan?= Date: Fri, 20 Oct 2023 15:38:15 +0100 Subject: [PATCH] feat(output_panel): clear entire buffer --- doc/neotest.txt | 8 ++++++++ lua/neotest/consumers/output_panel/init.lua | 11 ++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/doc/neotest.txt b/doc/neotest.txt index 19c3f100..0d05dcce 100644 --- a/doc/neotest.txt +++ b/doc/neotest.txt @@ -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* diff --git a/lua/neotest/consumers/output_panel/init.lua b/lua/neotest/consumers/output_panel/init.lua index 5270239e..a65949c2 100644 --- a/lua/neotest/consumers/output_panel/init.lua +++ b/lua/neotest/consumers/output_panel/init.lua @@ -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 @@ -23,6 +19,7 @@ neotest.output_panel = {} local init = function(client) panel = OutputPanel(client) + local chan ---@param results table client.listeners.results = function(adapter_id, results, partial) if partial then @@ -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, {