Skip to content
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

Focused window is lost after secondary float opens #169

Closed
aikixd opened this issue Jan 19, 2024 · 3 comments · Fixed by #184
Closed

Focused window is lost after secondary float opens #169

aikixd opened this issue Jan 19, 2024 · 3 comments · Fixed by #184
Labels
bug Something isn't working

Comments

@aikixd
Copy link

aikixd commented Jan 19, 2024

Neovim version (nvim -v)

0.10.0

Operating system/version

ubuntu 22.04

Output of :checkhealth rustaceanvim

---

How to reproduce the issue

Have two or more windows opened. Open code action in a non-leftmost window. Enter secondary float and close it ('q' or '<cr>').

Expected behaviour

Cursor to return to the window in which code action was invoked.

Actual behaviour

Cursor is returned to the leftmost window.

NB: I've made a temporary fix for myself by tracking the current window:
M.state.cur_win = vim.api.nvim_get_current_win() in on_code_action_results
vim.api.nvim_set_current_win(M.state.cur_win) in cleanup

My guess is that on window close, nvim moves caret to 'other' window. Since 2 are closed, there is no other window to use and the leftmost is chosen.

The minimal config used to reproduce this issue.

---
@aikixd aikixd added the bug Something isn't working label Jan 19, 2024
@mrcjkb
Copy link
Owner

mrcjkb commented Jan 19, 2024

Hey 👋

Thanks for reporting!
I don't quite understand the steps to reproduce. It tried with two splits, but couldn't reproduce the behaviour described.
Could you please rephrase it in terms of commands and key presses?
E.g.

nvim src/main.rs
:vsplit
<C-w>-l
:RustLsp codeAction
q
...

Screenshots or an asciinema recording/gif can also be helpful. 🙏

@aikixd
Copy link
Author

aikixd commented Jan 25, 2024

Sorry for the delay.
I've made a record with minimal config.
https://asciinema.org/a/Dbo3pcm21Ipgc5Amet6nEE6ET?t=59

I'm opening the code action twice:

  • one time i'm opening and closing the secondary with 'q'
  • second time i'm selecting an item in the secondary

Both times the cursor jumps to the left window.

NB: I'm using RustLsp codeAction, which isn't documented for some reason. Is it deprecated?

@mrcjkb
Copy link
Owner

mrcjkb commented Jan 25, 2024

Thanks 🙏

I was able to reproduce (didn't realise it was about the secondary float).

🤔 I guess I forgot to document it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants