-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Clear buffer: option to clear up to the current cursor line #18878
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
Two more bits of relevant information:
20250510-0047-50.2968362.mp4Sidenote: I only mention this for completeness, since whatever was the original issue that triggered the new behavior might have been related to how things work in CMD/PS, which I almost never use (and therefore how it's broken now is not something that I care much about :). |
I was able to kind of install VS in a VM, not really in a productive way (since each recompilation took around 30m), but I did manage to verify that the following code seem to work: {
const auto lock = _terminal->LockForWriting();
const til::point pos = _terminal->GetCursorPosition();
int ofs = ScrollOffset();
if (pos.y - ofs == 0)
{
// cursor is already at the top of the screen: just remove the scrollback
command = L"\x1b[3J";
}
else
{
command = fmt::format(L"\x1b[3J\x1b[H\x1b[{}M\x1b[1;{}H", pos.y - ofs, pos.x + 1);
}
} It's not ideal in releasing the lock just to re-grab it later when sending the string, but it does seem to do the trick. Re my last comment, it would be nice to have that working too (clearing up to the beginning of the current logical line), but given the 30m recompilation cycle I gave up. For reference, there is a control sequence for scrolling up, eg: |
Your suggested fix doesn't take into account that the buffers between ConPTY and Windows Terminal should stay mostly synchronized. This is the entire crux why this behavior can't be changed trivially. |
|
Description of the new feature
This is a followup to #18732, which is locked. The request there is to have an option to preserve the current line in
clearBuffer
.I don't have VS installed, so I can't play with the code, but I think that adding something like the below case to
ControlCore::ClearBuffer
should be very close to implementing this.[It will fail in case of editing multi-line inputs, but as I described in the other issue, this is still hugely useful as a default over the current always-remove-everything option. The one thing that bothers me more about this is that it uses the beginning of the current physical line rather than the logical line. If there's a way to get that information, it would be much better.]
Proposed technical implementation details
Disclaimer: mostly made-up code based on what I see in the file. Also assumes that there's a
.x
and.y
fields, and that they're 0-based.For reference, a bash version of this:
The text was updated successfully, but these errors were encountered: