-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Feature Request Move scroll buffer instead of clearing on CTRL+L and on clear #2832
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
Comments
As far as I know, clearing the scrollback buffer has been the expected behaviour of the
There are more details in the man page documenting the history of the change if you're interested. And if you don't like this behaviour, you may be able to update your terminfo to remove the E3 capability, which I think should get you the old behaviour. There's an answer on superuser.com describing how to do this for CentOS, which may also work for WSL (I haven't tried it myself). |
By old behavior, you mean the behavior of clearing scroll back buffer instead of just moving it? I am actually looking for behavior where scroll buffer is not cleared and I still have capability to scroll back and see older commands. |
On modern Linux systems, About clearing the current screen (but not the scrollback): The traditional way of implementing onscreen clear (without clearing the scrollback), e.g. the way xterm does it, is simply to erase the onscreen lines. This results in the last screenful of your work getting wiped out: e.g. execute Some terminals (e.g. VTE, and Konsole up until recently) think this is not what the user wants to have, and instead push these lines up into the scrollback buffer. [There is even a difference of 1 between the number of lines VTE scrolls vs. Konsole scrolled out. VTE scrolls one more, you often end up with a blank line. Konsole, however, wiped out the partial line before the cursor if your output didn't end in a newline.] [A terminal could even easily implement an adaptive scrollout, based on the cursor's location, or the actual onscreen nonempty vs. empty lines.]
See VTE 506438 for boring details, most of which are no longer relevant due to this recent fix in About clearing (or not) the scrollback: As of the aforementioned However, nothing stops a terminal from offering a config option to deliberately refuse to clear the scrollback, just as filed at VTE 771953 (not yet implemented). Not sure how much it's worth it. One could argue that user can just alias |
I hadn't noticed that |
I am coming here from gnome world(Ubuntu 18.0, Fedora Workstation). In gnome-terminal, CTRL+L and clear behave almost identically if not exactly. |
What ^L does is up to your shell, not up to the terminal. Sorry! |
Well, ^L emits the standard clear escape sequence, most likely I think both of them are equally valid, since probably no terminal emulation standard knows about a scrollback buffer. Anything that happens to the scrollback is unspecified territory. IMO in an ideal world all terminals and applications would agree on the behavior, decide whose responsibility it is to scroll out, and then consistently implement scrolling out the contents, since losing the last page of data is hardly likely what the user wants. Unfortunately there's no common agreement whether this should be the responsibility of the terminal or the application, hence the confusion and the hacks like vte's. So you can also change Windows Terminal's behavior to some extent and remain standards-complying. |
That’s fair, actually. I think that conhost implements scroll-off for ED 2, but perhaps somewhere in our translation later we are mishandling that. Standardization would be great 😄 |
I didn't spend enough time to understand how ctrl+l or clear work but it looks like when a virtual terminal is running, it handles ctrl+l and when it is not physical terminal handles it e.g. when I am using tmux on Windows terminal, ctrl+l is handled by tmux. It moves tmux's scroll buffer instead of clearing it. However, when tmux is not running, windows terminal handles it and clears the scroll buffer. |
iterm2 (mac) has "cmd+r" for the kind of clear that is just scrolling the contents off screen (but not clearing the buffer). I find this a useful form of clearing. It would be nice if there was a "command" for "clearByScroll" or something like that, so that we could assign our own keyboard shortcut for it. |
The Erase All VT sequence (`^[[2J`) is supposed to erase the entire contents of the viewport. The way it usually does this is by shifting the entirety of the viewport contents into scrollback, and starting the new viewport below it. Currently, conpty doesn't propagate that state change correctly. When conpty gets a 2J, it simply erases the content of the connected terminal's viewport, by writing over it with spaces. Conpty didn't really have a good way of communicating "your viewport should move", it only knew "the buffer is now full of spaces". This would lead to bugs like #2832, where pressing <kbd>ctrl+L</kbd> in `bash` would delete the current contents of the viewport, instead of moving the viewport down. This PR makes sure that when conpty sees a 2J, it passes that through directly to the connected terminal application as well. Fortunately, 2J was already implemented in the Windows Terminal, so this actually fixes the behavior of <kbd>ctrl+L</kbd>/`clear` in WSL in the Terminal. ## References * #4252 - right now this isn't the _most_ optimal scenario, we're literally just printing a 2J, then we'll perform "erase line" `height` times. The erase line operations are all redundant at this point - the entire viewport is blank, but conpty doesn't really know that. Fortunately, #4252 was already filed for me to come through and optimize this path. ## PR Checklist * [x] Closes #2832 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Validation Steps Performed * ran tests * compared <kbd>ctrl+L</kbd> with its behavior in conhost * compared `clear` with its behavior in conhost
The Erase All VT sequence (`^[[2J`) is supposed to erase the entire contents of the viewport. The way it usually does this is by shifting the entirety of the viewport contents into scrollback, and starting the new viewport below it. Currently, conpty doesn't propagate that state change correctly. When conpty gets a 2J, it simply erases the content of the connected terminal's viewport, by writing over it with spaces. Conpty didn't really have a good way of communicating "your viewport should move", it only knew "the buffer is now full of spaces". This would lead to bugs like #2832, where pressing <kbd>ctrl+L</kbd> in `bash` would delete the current contents of the viewport, instead of moving the viewport down. This PR makes sure that when conpty sees a 2J, it passes that through directly to the connected terminal application as well. Fortunately, 2J was already implemented in the Windows Terminal, so this actually fixes the behavior of <kbd>ctrl+L</kbd>/`clear` in WSL in the Terminal. ## References * #4252 - right now this isn't the _most_ optimal scenario, we're literally just printing a 2J, then we'll perform "erase line" `height` times. The erase line operations are all redundant at this point - the entire viewport is blank, but conpty doesn't really know that. Fortunately, #4252 was already filed for me to come through and optimize this path. ## PR Checklist * [x] Closes #2832 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Validation Steps Performed * ran tests * compared <kbd>ctrl+L</kbd> with its behavior in conhost * compared `clear` with its behavior in conhost
The Erase All VT sequence (`^[[2J`) is supposed to erase the entire contents of the viewport. The way it usually does this is by shifting the entirety of the viewport contents into scrollback, and starting the new viewport below it. Currently, conpty doesn't propagate that state change correctly. When conpty gets a 2J, it simply erases the content of the connected terminal's viewport, by writing over it with spaces. Conpty didn't really have a good way of communicating "your viewport should move", it only knew "the buffer is now full of spaces". This would lead to bugs like #2832, where pressing <kbd>ctrl+L</kbd> in `bash` would delete the current contents of the viewport, instead of moving the viewport down. This PR makes sure that when conpty sees a 2J, it passes that through directly to the connected terminal application as well. Fortunately, 2J was already implemented in the Windows Terminal, so this actually fixes the behavior of <kbd>ctrl+L</kbd>/`clear` in WSL in the Terminal. ## References * #4252 - right now this isn't the _most_ optimal scenario, we're literally just printing a 2J, then we'll perform "erase line" `height` times. The erase line operations are all redundant at this point - the entire viewport is blank, but conpty doesn't really know that. Fortunately, #4252 was already filed for me to come through and optimize this path. ## PR Checklist * [x] Closes #2832 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Validation Steps Performed * ran tests * compared <kbd>ctrl+L</kbd> with its behavior in conhost * compared `clear` with its behavior in conhost (cherry picked from commit 9fe624f)
It's not clear what the outcome is of this issue? |
There was a pull request that fixed it, and there was a fix, and that fix was committed, and that's the absolute most current status of this issue. |
I implemented support for passing through the EDIT: damn Dustin beat me |
🎉This issue was addressed in #5683, which has now been successfully released as Handy links: |
Hello, |
That depends very heavily on what she’ll you are using. It is your shell’s job to handle Ctrl+L. What shell are you using? |
As recommended in #5458, I emptied my settings file, so that defaults can be regenerated. |
Ctrl-L is literally ^L; (0x0C/FF/Form Feed) in ASCII. To quote wikipedia, it "moves a printer to top of next page". It does NOT move back up page, erasing what has gone before. So it should scroll the buffer, providing a clear page in the terminal, but preserving history, as if you were still using a teletype (which is what a video terminal is really; an advanced teletype that uses light instead of paper), and it had printed a bunch of blank lines. |
True, but the visual consequence is that the visible area is cleared, I actually don't really care how it should be done, but just that I want it to be doable using |
Description of the new feature/enhancement
On WSL, Typing
clear
or pressingCTRL+L
clears the scroll buffer history while most Linux terminals(both real ones like gnome-terminal, and virtual ones like tmux) move the scroll history instead of clearing it. Can we use same semantics for Windows Terminal?The text was updated successfully, but these errors were encountered: