When suspending Vim or Vi to the background with Ctrl+Z, the terminal is "cleared", leaving the prompt at the top of the window. This is not the case when using Neovim, it instead just adds a few new lines at the bottom of the terminal, leaving the prompt at the bottom.
The behavior of Neovim is identical to that of Vim and Vi when using them in the other terminal emulators I've tried (xterm and Konsole), so I'm thinking this is a bug in kitty and not Neovim itself, although I'm not certain of that, of course.
I see the same behavior with ctrl-z in nvim with VTE based terminals such as gnome-terminal and termite and in xterm (haven't tried konsole). IIRC in nvim you are supposed to use :terminal to access a terminal rather than ctrl-Z.
And generally speaking, the terminal emulator cannot know when a sub-program running in it is suspended. It is the job of the subprogram to issue the escape codes to clear the screen before suspending itself (i.e. when it receives the SIGSTOP signal).
@justinmk might want to comment
Oh, I'm sorry, seems I was sloppy in my testing. I'm running tmux in kitty, and it looks like that is what's causing the problem. My bad!
I see the same behavior with ctrl-z in nvim with VTE based terminals such as gnome-terminal
@kovidgoyal That's extremely unusual. Maybe the terminfo db is missing the relevant entry?
It doesn't happen in Vim because Vim merges its built-in terminfo entries with whatever is found on the system.
Nvim currently:
See also https://github.com/neovim/neovim/issues/7798
I'm running tmux in kitty, and it looks like that is what's causing the problem.
@ahstro It should still work in tmux. But there it sounds like either your system terminfo corresponding to screen-256colors or Nvim's builtin are missing the relevent entry (see above).
kitty's terminfo most definitely has smcup and rmcup and I would be very surprised if VTE based terminals are missing it. You can check that in any terminal via
infocmp | grep mcup
Of course, with tmux, all bets are off.
ALso the very fact that nvim is switching to the alternate scren in the first place, means it must be reading the *mcup properties.
When suspending Vim or Vi to the background with Ctrl+Z, the terminal is "cleared", leaving the prompt at the top of the window. This is not the case when using Neovim, it instead just adds a few new lines at the bottom of the terminal, leaving the prompt at the bottom.
This description is ambiguous to me. When I use ctrl-z in Nvim, it shows the alternate screen, i.e. the Nvim UI is hidden. From @ahstro 's description it sounds like the Nvim UI is only "nudged upwards".
The ambiguous part is:
the terminal is "cleared", leaving the prompt at the top of the window.
Only the Nvim UI should be hidden, and the "original" shell should be shown in its previous state. It should not be "cleared" to the top.
the very fact that nvim is switching to the alternate scren in the first place
Yes, but my understanding of the issue described by @ahstro is that the alternate screen is _not_ invoked.
Yeah, on my system, in all the terminals I tested, both nvim and vim behave the same way -- i.e. the terminal switch back to the main screen showing whatever was on the screen before starting (n)vim. The screen is not cleared. I did not test with tmux however, I suspect the issue, if any, is related to tmux changing the TERM variable and nvim not falling back to a hardcoded mcup definition in this case, unlike vim.
Sorry about my use of the word _cleared_, I didn't know about alternate screens so didn't have the proper vocabulary to describe what should've been happening.
You're right that the issue was not with kitty, but with tmux or nvim, depending on how you see it. I had set the default-terminal tmux configuration option to "tmux-256color"; removing it and restarting tmux solved the issue (and $TERM is now xterm-kitty).
Thank you for helping me solve this! :blush:
removing it and restarting tmux solved the issue (and $TERM is now xterm-kitty).
I wouldn't recommend that. In tmux, $TERM should not be anything except screen-256color or tmux-256color. If you're in tmux, then the terminal _is_ tmux, as far as child applications are concerned.
We will fix this issue in Nvim, we need to enhance our builtin tmux terminfo definition.
You're welcome :)
Most helpful comment
I wouldn't recommend that. In tmux, $TERM should not be anything except
screen-256colorortmux-256color. If you're in tmux, then the terminal _is_ tmux, as far as child applications are concerned.We will fix this issue in Nvim, we need to enhance our builtin tmux terminfo definition.