Skip to content

Commit

Permalink
feat(summary): nowait mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
rcarriga committed Sep 11, 2022
1 parent 1b83929 commit 60b11a2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lua/neotest/consumers/output.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ 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"),
row = 0,
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
Expand Down
1 change: 1 addition & 0 deletions lua/neotest/consumers/summary/canvas.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 7 additions & 2 deletions lua/neotest/consumers/summary/component.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

Expand Down

0 comments on commit 60b11a2

Please sign in to comment.