|
|
|
@@ -28,6 +28,7 @@ local state = {
|
|
|
|
|
trigger_cursor = nil,
|
|
|
|
|
listing_unfiltered_lines = nil,
|
|
|
|
|
listing_filtered_kind = nil,
|
|
|
|
|
detail_line = nil,
|
|
|
|
|
hardtime_refcount = 0,
|
|
|
|
|
hardtime_was_enabled = false,
|
|
|
|
|
autocmds_set = false,
|
|
|
|
@@ -37,6 +38,7 @@ local summary_ns = vim.api.nvim_create_namespace("TestSamuraiSummary")
|
|
|
|
|
local result_ns = vim.api.nvim_create_namespace("TestSamuraiResult")
|
|
|
|
|
local detail_ns = vim.api.nvim_create_namespace("TestSamuraiDetailAnsi")
|
|
|
|
|
local help_ns = vim.api.nvim_create_namespace("TestSamuraiHelp")
|
|
|
|
|
local listing_sel_ns = vim.api.nvim_create_namespace("TestSamuraiListingSelection")
|
|
|
|
|
local apply_border_kind
|
|
|
|
|
local close_container
|
|
|
|
|
local restore_listing_full
|
|
|
|
@@ -100,6 +102,7 @@ local function help_lines()
|
|
|
|
|
"",
|
|
|
|
|
"Notes:",
|
|
|
|
|
" No output captured -> shows placeholder text",
|
|
|
|
|
" Active listing entry is highlighted while Detail-Float is visible",
|
|
|
|
|
" Buffers are saved via :wall before every test run",
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
@@ -149,6 +152,7 @@ local function apply_listing_lines(buf, lines)
|
|
|
|
|
vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
|
|
|
|
|
vim.api.nvim_buf_clear_namespace(buf, result_ns, 0, -1)
|
|
|
|
|
vim.api.nvim_buf_clear_namespace(buf, summary_ns, 0, -1)
|
|
|
|
|
vim.api.nvim_buf_clear_namespace(buf, listing_sel_ns, 0, -1)
|
|
|
|
|
apply_result_highlights(buf, 0, lines)
|
|
|
|
|
apply_summary_highlights(buf, 0, lines)
|
|
|
|
|
rebuild_result_line_map(lines)
|
|
|
|
@@ -382,6 +386,30 @@ local function jump_listing_and_open(kind)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function clear_listing_selection()
|
|
|
|
|
if state.last_buf and vim.api.nvim_buf_is_valid(state.last_buf) then
|
|
|
|
|
vim.api.nvim_buf_clear_namespace(state.last_buf, listing_sel_ns, 0, -1)
|
|
|
|
|
end
|
|
|
|
|
state.detail_line = nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function apply_listing_selection(line)
|
|
|
|
|
if not (state.last_buf and vim.api.nvim_buf_is_valid(state.last_buf)) then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
vim.api.nvim_buf_clear_namespace(state.last_buf, listing_sel_ns, 0, -1)
|
|
|
|
|
if not line then
|
|
|
|
|
state.detail_line = nil
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
local total = vim.api.nvim_buf_line_count(state.last_buf)
|
|
|
|
|
if line < 1 or line > total then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
vim.api.nvim_buf_add_highlight(state.last_buf, listing_sel_ns, "TestSamuraiListingActive", line - 1, 0, -1)
|
|
|
|
|
state.detail_line = line
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function find_normal_window()
|
|
|
|
|
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
|
|
|
|
|
local cfg = vim.api.nvim_win_get_config(win)
|
|
|
|
@@ -534,6 +562,7 @@ local function setup_summary_highlights()
|
|
|
|
|
pcall(vim.api.nvim_set_hl, 0, "TestSamuraiResultSkip", { fg = skip_fg })
|
|
|
|
|
pcall(vim.api.nvim_set_hl, 0, "TestSamuraiBorderPass", { fg = pass_fg, bold = true })
|
|
|
|
|
pcall(vim.api.nvim_set_hl, 0, "TestSamuraiBorderFail", { fg = fail_fg, bold = true })
|
|
|
|
|
pcall(vim.api.nvim_set_hl, 0, "TestSamuraiListingActive", { link = "Visual" })
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function load_runners()
|
|
|
|
@@ -567,6 +596,7 @@ local function ensure_output_autocmds()
|
|
|
|
|
if state.detail_win and closed == state.detail_win then
|
|
|
|
|
state.detail_win = nil
|
|
|
|
|
restore_listing_full()
|
|
|
|
|
clear_listing_selection()
|
|
|
|
|
hardtime_restore()
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
@@ -577,6 +607,7 @@ local function ensure_output_autocmds()
|
|
|
|
|
pcall(vim.api.nvim_win_close, state.detail_win, true)
|
|
|
|
|
state.detail_win = nil
|
|
|
|
|
end
|
|
|
|
|
clear_listing_selection()
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end,
|
|
|
|
@@ -744,6 +775,7 @@ close_container = function()
|
|
|
|
|
pcall(vim.api.nvim_win_close, state.last_win, true)
|
|
|
|
|
state.last_win = nil
|
|
|
|
|
end
|
|
|
|
|
clear_listing_selection()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function close_container_and_restore()
|
|
|
|
@@ -763,6 +795,7 @@ close_detail_float = function()
|
|
|
|
|
if state.detail_win and vim.api.nvim_win_is_valid(state.detail_win) then
|
|
|
|
|
pcall(vim.api.nvim_win_close, state.detail_win, true)
|
|
|
|
|
end
|
|
|
|
|
clear_listing_selection()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
restore_listing_full = function()
|
|
|
|
@@ -1472,10 +1505,12 @@ function M.open_test_output_at_cursor()
|
|
|
|
|
end
|
|
|
|
|
if type(output) ~= "table" or #output == 0 then
|
|
|
|
|
open_detail_split({ "", "No output captured" }, "default")
|
|
|
|
|
apply_listing_selection(line)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
local border_kind = status and status:lower() or nil
|
|
|
|
|
open_detail_split(output, border_kind)
|
|
|
|
|
apply_listing_selection(line)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M.show_help()
|
|
|
|
@@ -1485,6 +1520,7 @@ function M.show_help()
|
|
|
|
|
end
|
|
|
|
|
local lines = help_lines()
|
|
|
|
|
open_detail_split(lines, "default")
|
|
|
|
|
clear_listing_selection()
|
|
|
|
|
apply_help_highlights(state.detail_buf, lines)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|