Floating window for summary pane
sahilsehwag opened this issue · comments
It would be amazing if we could have support for showing summary pane as a floating window, since a lot of times, the test description strings are long. So floating window seems better for those kind of scenarios
So I've gone with not adding built-in floating windows but rather leaving the opening of the window to the user to give the most flexibility and to reduce complexity within the plugin (want to avoid more translating between Vim and NeoVim options).
To have a floating summary you can do something like this (assuming you're using NeoVim)
function M.open_summary()
local round = function (num) return math.floor(num + 0.5) end
vim.api.nvim_open_win(0, true, {
relative = "editor",
row = vim.opt.lines:get() * 0.1,
col = vim.opt.columns:get() * 0.1,
height = round(vim.opt.lines:get() * 0.8),
width = round(vim.opt.columns:get() * 0.8),
border = "rounded",
})
end
and then in your config have
vim.g.ultest_summary_open = "lua require('<module containing the above function>').open_summary()"
The above code just opens the summary pane in floating window,
- It doesn't focus the floating summary window.
- Mappings to execute test cases and others are not working
- I don't want to create a different lua module just to import here, its better if we can manager a plugin config in a single file instead of creating multiple files.
- There is a separate plug mapping for that
<Plug>(ultest-summary-jump)
which will open if needed, and focus the window. - Mappings are working, there was a separate issue from another change. Please try latest commit.
- The above is purely an example, you can implement however you want, such as in vimscript. You could do it a single line of vimscript if you wanted to
let g:ultest_summary_open = 'call nvim_open_win(nvim_get_current_buf(), 1, { "relative" : "editor", "row" : &lines * 0.1, "col": &columns * 0.1, "height": float2nr(round(&lines * 0.8)), "width": float2nr(round(&columns * 0.8)), "border": "rounded" })'
Nice. Thanks @rcarriga. I appreciate the help.
- Is there a way to open and jump in a single step? Its cumbersome to open the window and then focus on this?
- All the flows that relates to jumps are same, ie floating window remains open after jumping to test case or similar flows, Is there a way to close it after losing focus?
- Opening the output window and closing it makes it focus the background instead of same floating window, is there a way to keep it focused in such flows?
- The plug mapping above does that, but I realised there's no way to toggle and jump in one. The
UltestSummary
now accepts a bang (UltestSummary!
) to also jump to the window when opened. - That's a bit of a tough one to get right because you don't want to close when opening an output, I'll have to take some time to think about that one
- This is due to the way the output closed, it should jump back to the summary window in latest commit 😄
That works, Thanks @rcarriga .
- Do update us here, if the the second point mentioned above, gets resolved.
- I am at the latest commit, but the I am still unable to run tests from the Summary panel, The mappings for seeing the output in the summary panel is working, but the run mappings in the summary panel are not working.
Sorry @sahilsehwag been quite busy, if some mappings are working then it sounds like a different issue. Can you post the details specified in the bug report template please. Do the tests you're trying to run work as expected when using :Ultest
/:UltestNearest
?