From 60b11a2d5c4af97e0e42aa62436822e19e3ef9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3n=C3=A1n=20Carrigan?= Date: Sun, 11 Sep 2022 22:17:22 +0100 Subject: [PATCH] feat(summary): nowait mappings --- lua/neotest/consumers/output.lua | 6 ++++-- lua/neotest/consumers/summary/canvas.lua | 1 + lua/neotest/consumers/summary/component.lua | 9 +++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lua/neotest/consumers/output.lua b/lua/neotest/consumers/output.lua index 6c4a53cc..d288cd0e 100644 --- a/lua/neotest/consumers/output.lua +++ b/lua/neotest/consumers/output.lua @@ -14,7 +14,7 @@ local function open_output(result, opts) end local buf = async.api.nvim_create_buf(false, true) -- nvim_open_term uses the current window for determining width/height for truncating lines - local temp_win = async.api.nvim_open_win(buf, true, { + local success, temp_win = pcall(async.api.nvim_open_win, buf, true, { relative = "editor", width = async.api.nvim_get_option("columns"), height = async.api.nvim_get_option("lines"), @@ -22,7 +22,9 @@ local function open_output(result, opts) col = 0, }) local chan = async.api.nvim_open_term(buf, {}) - vim.api.nvim_win_close(temp_win, true) + if success then + vim.api.nvim_win_close(temp_win, true) + end short_opened = opts.short -- See https://github.com/neovim/neovim/issues/14557 diff --git a/lua/neotest/consumers/summary/canvas.lua b/lua/neotest/consumers/summary/canvas.lua index f0d73497..efe3a8d6 100644 --- a/lua/neotest/consumers/summary/canvas.lua +++ b/lua/neotest/consumers/summary/canvas.lua @@ -126,6 +126,7 @@ function Canvas:render_buffer(buffer) for _, key in ipairs(action_keys) do vim.api.nvim_buf_set_keymap(buffer, "n", key, "", { noremap = true, + nowait = true, callback = function() for _, callback in pairs(mappings[vim.fn.line(".")] or {}) do callback() diff --git a/lua/neotest/consumers/summary/component.lua b/lua/neotest/consumers/summary/component.lua index 8efed690..00e64a57 100644 --- a/lua/neotest/consumers/summary/component.lua +++ b/lua/neotest/consumers/summary/component.lua @@ -180,14 +180,19 @@ function SummaryComponent:_render(canvas, tree, expanded, focused, indent) canvas:add_mapping( "output", async_func(function() - neotest.output.open({ position_id = position.id, adapter = self.adapter_id }) + neotest.output.open({ position_id = position.id, adapter = self.adapter_id, enter = true }) end) ) canvas:add_mapping( "short", async_func(function() - neotest.output.open({ position_id = position.id, short = true, adapter = self.adapter_id }) + neotest.output.open({ + position_id = position.id, + short = true, + adapter = self.adapter_id, + enter = true, + }) end) )