Skip to content

Floating window for summary pane #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sahilsehwag opened this issue Sep 13, 2021 · 7 comments
Open

Floating window for summary pane #67

sahilsehwag opened this issue Sep 13, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@sahilsehwag
Copy link

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

@rcarriga rcarriga added the enhancement New feature or request label Sep 14, 2021
rcarriga added a commit that referenced this issue Sep 26, 2021
@rcarriga
Copy link
Owner

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()"

@sahilsehwag
Copy link
Author

sahilsehwag commented Sep 26, 2021

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.

@rcarriga
Copy link
Owner

  1. There is a separate plug mapping for that <Plug>(ultest-summary-jump) which will open if needed, and focus the window.
  2. Mappings are working, there was a separate issue from another change. Please try latest commit.
  3. 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" })'

@sahilsehwag
Copy link
Author

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?

@rcarriga
Copy link
Owner

  1. 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.
  2. 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
  3. This is due to the way the output closed, it should jump back to the summary window in latest commit 😄

@sahilsehwag
Copy link
Author

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.

@rcarriga
Copy link
Owner

rcarriga commented Oct 6, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants