expand opening keymap on detail-float
All checks were successful
tests / test (push) Successful in 8s

This commit is contained in:
2026-01-23 10:42:25 +01:00
parent 456a157549
commit 5d205c0302
4 changed files with 176 additions and 40 deletions

View File

@@ -70,7 +70,7 @@ local function help_lines()
" <leader>fn [F]ind [N]ext failed test in listing (opens Detail-Float; works in Detail-Float)",
" <leader>fp [F]ind [P]revious failed test in listing (opens Detail-Float; works in Detail-Float)",
" <leader>ff [F]ind [F]irst list entry (opens Detail-Float; works in Detail-Float)",
" <leader>o Jump to test location",
" <leader>o Jump to test location (works in Detail-Float)",
" <leader>qn Close floats + jump to first quickfix entry",
"",
"Listing filters:",
@@ -469,9 +469,27 @@ local function restore_trigger_location()
end
local function jump_to_listing_test()
local cursor = vim.api.nvim_win_get_cursor(0)
local line = cursor[1]
local text = vim.api.nvim_get_current_line()
local line = nil
local text = nil
local buf = vim.api.nvim_get_current_buf()
if state.detail_buf and buf == state.detail_buf then
if not (state.last_buf and vim.api.nvim_buf_is_valid(state.last_buf)) then
return
end
line = state.detail_line
if not line then
return
end
local lines = vim.api.nvim_buf_get_lines(state.last_buf, line - 1, line, false)
text = lines and lines[1] or nil
else
local cursor = vim.api.nvim_win_get_cursor(0)
line = cursor[1]
text = vim.api.nvim_get_current_line()
end
if not line or not text then
return
end
local status = text:match("^%[%s*(%u+)%s*%]%s*%-")
if status ~= "PASS" and status ~= "FAIL" and status ~= "SKIP" then
return
@@ -1340,6 +1358,46 @@ local function parse_go_output_from_raw(output)
return out
end
local function set_detail_maps(buf)
vim.keymap.set("n", "<esc><esc>", function()
close_container_and_restore()
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "<C-w>h", function()
M.focus_listing()
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "<C-h>", function()
M.focus_listing()
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "<C-l>", function()
M.focus_detail()
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "<leader>z", function()
M.toggle_detail_full()
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "<leader>fn", function()
jump_listing_and_open("next")
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "<leader>fp", function()
jump_listing_and_open("prev")
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "<leader>ff", function()
jump_listing_and_open("first")
end, { buffer = buf, nowait = true, silent = true, desc = "[F]ind [F]irst list entry" })
vim.keymap.set("n", "<C-c>", function()
close_detail_float()
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "<leader>qn", function()
jump_to_first_quickfix()
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "<leader>o", function()
jump_to_listing_test()
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "?", function()
M.show_help()
end, { buffer = buf, nowait = true, silent = true })
disable_container_maps(buf)
end
local function ensure_detail_buf(lines)
local buf = state.detail_buf
if not (buf and vim.api.nvim_buf_is_valid(buf)) then
@@ -1349,41 +1407,8 @@ local function ensure_detail_buf(lines)
vim.api.nvim_buf_set_option(buf, "swapfile", false)
vim.api.nvim_buf_set_option(buf, "filetype", "test-samurai-output")
state.detail_buf = buf
vim.keymap.set("n", "<esc><esc>", function()
close_container_and_restore()
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "<C-w>h", function()
M.focus_listing()
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "<C-h>", function()
M.focus_listing()
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "<C-l>", function()
M.focus_detail()
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "<leader>z", function()
M.toggle_detail_full()
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "<leader>fn", function()
jump_listing_and_open("next")
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "<leader>fp", function()
jump_listing_and_open("prev")
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "<leader>ff", function()
jump_listing_and_open("first")
end, { buffer = buf, nowait = true, silent = true, desc = "[F]ind [F]irst list entry" })
vim.keymap.set("n", "<C-c>", function()
close_detail_float()
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "<leader>qn", function()
jump_to_first_quickfix()
end, { buffer = buf, nowait = true, silent = true })
vim.keymap.set("n", "?", function()
M.show_help()
end, { buffer = buf, nowait = true, silent = true })
disable_container_maps(buf)
end
set_detail_maps(buf)
local clean_lines, highlights = parse_ansi_lines(normalize_output_lines(lines))
vim.api.nvim_buf_set_lines(buf, 0, -1, false, clean_lines)
vim.api.nvim_buf_clear_namespace(buf, help_ns, 0, -1)