emacs-libvterm
emacs-libvterm copied to clipboard
Trouble with vterm-clear affecting buffer history
First, thanks for the great package.
I'm having trouble with vterm-clear
destroying buffer history in strange ways. I currently have vterm-clear-scrollback-when-clearing
set to nil
, so vterm-clear
is not calling vterm-clear-scrollback
directly. However, the odd behavior I'm seeing can be described in two scenarios:
-
If I open a new
vterm
buffer and type some commands whose output does not cause the buffer to scroll (e.g.,pwd
), and then type eitherC-l
,M-x vterm-clear
, orM-x vterm-send-C-l
, the buffer is cleared and scrollback is cleared. I'm effectively seeing the same behavior as if I had runC-c C-l
. -
If I open a new
vterm
buffer and type some commands whose output does cause the buffer to scroll (e.g.,find /
), and then type eitherC-l
,M-x vterm-clear
, orM-x vterm-send-C-l
, the buffer is cleared as expected but scrollback is not cleared and I can move point up to see previous lines. However, at this point if I type subsequent commands which do not cause the buffer to scroll (e.g.,pwd
) and then again typeC-l
, the history of my last (short output) command is lost. When I scroll up I only see the original command and its output which caused the buffer to scroll (in my example,find /
).
Thanks for any assistance.
OS: macOS 10.15.7 Emacs: 27.2 Emacs-libvterm: sha 2681120 (current origin/master HEAD) libvterm: I let the libvterm package install its own version
got this issue too. /usr/bin/clear
or tput clear
sends <ESC>[H<ESC>[2J
to vterm:
<ESC>[H
: move to position (1,1)
<ESC>[2J
: clear all screen, not include saved lines and alternative screen.
Although vterm-clear-scrollback-when-clearing
is nil
, but the text content in current screen before clear isn't saved to scrollback buffer, so you can scroll back to previous screen, but can't scroll back to latest output:
before clear:
xxxxx <- on previous screen, in scroll buffer
-----> begin of current screen
yyyyy <- on current screen
$ tput clear <- emit command
<----end of current screen
after clear, "yyyyy" is missing, this isn't consistent with the behaviour of other terminal emulator.
xxxxx <- on previous screen, STILL in scroll buffer
-----> begin of current screen
$ <- prompt here, but you can't scroll back to see "yyyyy" any more.
<----end of current screen
@Dieken Glad it's not just me then. Because libvterm is running as an (often small) Emacs window, I find that I press C-l
a lot more than I would in a dedicated terminal application, so this issue affects me more than it would otherwise. I can't really rely on libvterm history at this point - whether the command/output is present in the history depends on whether it caused the buffer to scroll or not.
I'm also seeing this behavior on macOS, with default vterm configuration. C-l
/ vterm-clear
always clears scrollback.
I have the same behaviour with the following setup
OS: Ubuntu 20.04 Emacs: 28.2 Emacs-libvterm: sha 94e2b0b libvterm: 0.1.2-2