show automatically the details after keymap navigating to a failed test entry
This commit is contained in:
@@ -65,9 +65,9 @@ local function help_lines()
|
||||
" TSamShowOutput <leader>to",
|
||||
"",
|
||||
"Listing navigation:",
|
||||
" <leader>fn [F]ind [N]ext failed test in listing",
|
||||
" <leader>fp [F]ind [P]revious failed test in listing",
|
||||
" <leader>ff [F]ind [F]irst list entry",
|
||||
" <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>qn Close floats + jump to first quickfix entry",
|
||||
"",
|
||||
@@ -278,11 +278,11 @@ local function jump_listing_fail(direction)
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
if not (buf and vim.api.nvim_buf_is_valid(buf)) then
|
||||
return
|
||||
return nil
|
||||
end
|
||||
local total = vim.api.nvim_buf_line_count(buf)
|
||||
if total == 0 then
|
||||
return
|
||||
return nil
|
||||
end
|
||||
local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false)
|
||||
local cursor = vim.api.nvim_win_get_cursor(win)
|
||||
@@ -334,25 +334,52 @@ local function jump_listing_fail(direction)
|
||||
if target then
|
||||
vim.api.nvim_win_set_cursor(win, { target, 0 })
|
||||
end
|
||||
return target
|
||||
end
|
||||
|
||||
local function jump_to_first_listing_entry()
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
if not (buf and vim.api.nvim_buf_is_valid(buf)) then
|
||||
return
|
||||
return nil
|
||||
end
|
||||
local total = vim.api.nvim_buf_line_count(buf)
|
||||
if total == 0 then
|
||||
return
|
||||
return nil
|
||||
end
|
||||
local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false)
|
||||
for i = 1, total do
|
||||
if lines[i] and lines[i]:match("^%[ %u+ %] %- ") then
|
||||
vim.api.nvim_win_set_cursor(win, { i, 0 })
|
||||
return
|
||||
return i
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function jump_listing_and_open(kind)
|
||||
local current_win = vim.api.nvim_get_current_win()
|
||||
local listing_win = state.last_win
|
||||
if listing_win and vim.api.nvim_win_is_valid(listing_win) then
|
||||
vim.api.nvim_set_current_win(listing_win)
|
||||
else
|
||||
listing_win = current_win
|
||||
end
|
||||
local target = nil
|
||||
if kind == "next" then
|
||||
target = jump_listing_fail("next")
|
||||
elseif kind == "prev" then
|
||||
target = jump_listing_fail("prev")
|
||||
elseif kind == "first" then
|
||||
target = jump_to_first_listing_entry()
|
||||
end
|
||||
if target then
|
||||
M.open_test_output_at_cursor()
|
||||
return
|
||||
end
|
||||
if current_win and vim.api.nvim_win_is_valid(current_win) then
|
||||
vim.api.nvim_set_current_win(current_win)
|
||||
end
|
||||
end
|
||||
|
||||
local function find_normal_window()
|
||||
@@ -859,13 +886,13 @@ local function create_output_win(initial_lines)
|
||||
M.toggle_detail_full()
|
||||
end, { buffer = buf, nowait = true, silent = true })
|
||||
vim.keymap.set("n", "<leader>fn", function()
|
||||
jump_listing_fail("next")
|
||||
jump_listing_and_open("next")
|
||||
end, { buffer = buf, nowait = true, silent = true })
|
||||
vim.keymap.set("n", "<leader>fp", function()
|
||||
jump_listing_fail("prev")
|
||||
jump_listing_and_open("prev")
|
||||
end, { buffer = buf, nowait = true, silent = true })
|
||||
vim.keymap.set("n", "<leader>ff", function()
|
||||
jump_to_first_listing_entry()
|
||||
jump_listing_and_open("first")
|
||||
end, { buffer = buf, nowait = true, silent = true, desc = "[F]ind [F]irst list entry" })
|
||||
vim.keymap.set("n", "<leader>cb", function()
|
||||
M.listing_break_on_dashes()
|
||||
@@ -948,13 +975,13 @@ local function reopen_output_win()
|
||||
M.toggle_detail_full()
|
||||
end, { buffer = state.last_buf, nowait = true, silent = true })
|
||||
vim.keymap.set("n", "<leader>fn", function()
|
||||
jump_listing_fail("next")
|
||||
jump_listing_and_open("next")
|
||||
end, { buffer = state.last_buf, nowait = true, silent = true })
|
||||
vim.keymap.set("n", "<leader>fp", function()
|
||||
jump_listing_fail("prev")
|
||||
jump_listing_and_open("prev")
|
||||
end, { buffer = state.last_buf, nowait = true, silent = true })
|
||||
vim.keymap.set("n", "<leader>ff", function()
|
||||
jump_to_first_listing_entry()
|
||||
jump_listing_and_open("first")
|
||||
end, { buffer = state.last_buf, nowait = true, silent = true, desc = "[F]ind [F]irst list entry" })
|
||||
vim.keymap.set("n", "<leader>cb", function()
|
||||
M.listing_break_on_dashes()
|
||||
@@ -1304,6 +1331,15 @@ local function ensure_detail_buf(lines)
|
||||
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 })
|
||||
|
||||
Reference in New Issue
Block a user