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

Moving cursor forces user out of terminal mode (i3) #1838

Closed
Algorhythm-sxv opened this issue Apr 15, 2023 · 9 comments · Fixed by #2111
Closed

Moving cursor forces user out of terminal mode (i3) #1838

Algorhythm-sxv opened this issue Apr 15, 2023 · 9 comments · Fixed by #2111
Labels
bug Something isn't working

Comments

@Algorhythm-sxv
Copy link

Describe the bug
When a terminal buffer is open and in terminal node, moving the cursor inside the neovide window forces the user into normal mode. This does not occur when in e.g. insert mode in a text buffer, and is only present in neovide, not terminal neovim.

To Reproduce
Steps to reproduce the behavior:

  1. run :terminal and enter terminal mode
  2. move the mouse cursor inside the neovide window

Expected behavior
The buffer remains in terminal mode until keyboard input forces it out

Desktop (please complete the following information):

  • OS: Arch Linux
  • Neovide Version 0.10.4
  • Neovim Version 0.9.0

Please run neovide --log and paste the contents of the .log file created in the current directory here:
Log is very long (2670 lines). I can provide it elsewhere if necessary.

@Algorhythm-sxv Algorhythm-sxv added the bug Something isn't working label Apr 15, 2023
@sa-mendez
Copy link

I am experiencing this as well. It appears to have started happening in Neovide version 0.10.4 in confjunction with Neovim Version 0.9, as it was not happening to me before that.

@amv-dev
Copy link

amv-dev commented May 13, 2023

I have the same problem.
Linux 6.1 / X11 21.1.8 / Gnome 43.5.

The problem appears after 5b4ae91

Also looks like this bug relates to #1833

@amv-dev
Copy link

amv-dev commented May 13, 2023

Found temporal solution.
tnoremap <MouseMove> <NOP>
or
vim.keymap.set("t", "<MouseMove>", "<NOP>")

@TheDreadedAndy
Copy link

Found temporal solution.
tnoremap <MouseMove> <NOP>
or
vim.keymap.set("t", "<MouseMove>", "<NOP>")

That resolved the issue for me, but it also hints at what the actual problem is: Neovide is ignoring the value of mousemoveevent and always sending <MouseMove>. If you set mousemoveevent while running Neovim in a terminal, the issue is present there as well.

The documentation for the Neovim terminal is worded in such a way that I can't tell if this is a bug or not. I think it's not, since the help file says focus is lost from the terminal if the program running in it doesn't catch a mouse event.

@fredizzimo
Copy link
Member

Yes, we should fix the mousemoveevent option. The issue was known by the author of the feature that added the mouse movement support, but it was merged a bit prematurely #1766

@9mm
Copy link
Contributor

9mm commented Sep 13, 2023

@amv-dev awesome thanks for this

@fredizzimo
Copy link
Member

fredizzimo commented Sep 13, 2023

@9mm, I'm answering this here (from #1988 (comment)):

With that said... what actually makes the mousemoveevent ignore the floating window? Wouldnt it make sense if it floated back onto the window when the mouse is back over it? or is that not how it works. No need to really answer just curious if you feel like it.

@TheDreadedAndy, explained why that happens, More specifically these lines in the documentation https://github.com/neovim/neovim/blob/27a566f3f8e07a4cebb426674800bdf9a7f4f222/runtime/doc/nvim_terminal_emulator.txt#L92-L93

  • If mouse events are disabled (the default), terminal focus will be lost and
    the event will be processed as in a normal buffer.

What this really means, is that it will exit the terminal mode unless the terminal app you are running handles the mouse:
For example, if you run this in your terminal:
dialog --yesno "Are you OK?" 5 20

Then it will stay in the terminal mode as long as the dialog is open, and you can click the buttons with the mouse.

The reason why properly respecting mousemovementevent fixes the issue, is that it defaults to off. And then it only sends mouse events when you actually click something. But now we are sending it all the time, so it exits the terminal mode as soon as you move the mouse.

NOTE: You might want to have mousemovementevent enabled if you are using a terminal application that draws a mouse cursor. But otherwise, you probably only want to have it for regular buffers for LSP hover support for example.

@fredizzimo
Copy link
Member

fredizzimo commented Sep 13, 2023

And thinking more about it, I think this is something that should be reconsidered on the Neovim side as well.

It makes totally sense that mouse clicks exit the terminal mode, so that you are able to easily select and copy some text. But I can't really see any use cases of exiting the terminal mode when the mouse is moved.

Edit: The scroll wheel should also probably exit the terminal mode

@Crispy13
Copy link

Is this issue resolved?
I'm experiencing the exact same thing

When I move the mouse, it automatically enters normal mode from terminal mode.

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.

7 participants