-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Support manually clearing the conpty buffer #1193
Comments
Thoughts: new thing to put on the signal pipe? We don't want to introduce too many non-standard VT things to the in/out pipes, so the signal pipe is our "get out of jail free" card. |
I don't think this is a good idea for that reason. |
Sorry, I think you'll need to be more specific about what |
|
So, okay, if I understand this correctly: |
I think there's a bug as @zadjii-msft indicated in the linked issue that I want fixed instead of adding non-standard stuff to conpty. Setting a variable and printing it in Python should not redraw the entire screen, see microsoft/vscode#75141 (comment) for context. |
Well, I think the bug might be making this issue more apparent, but I don't think fixing the bug mentioned will actually properly resolve this issue. It might temporarily hide the issue, by allowing the cursor to start printing text again at the origin. However, the text wouldn't actually be at the origin in conpty's buffer, and it's entirely possible that another action could cause conpty to need to redraw everything - at which point, all the old text would re-appear, and the new text would suddenly shift to where conpty thinks it is. For *nix, VSCode's terminal clear works just fine because the pty is just a dumb pipe - when you clear the frontend's buffer, there's nothing on the backend that still thinks that there's any text in the buffer, because there is no buffer. However, with conpty, because there is an actual buffer on the backend, we can't just clear the frontend like that. The conpty buffer will still think something's there. Since this is a problem unique to conpty & windows, I think it's unfortunately something that needs a unique solution. I really want to make sure we avoid API creep on the conpty API though. We need to make sure that this is something that's definitely not accomplish-able by some other means. |
@zadjii-msft I get that there will be times when it fails just as it will on nix (eg. running clear in the alt buffer) and I'm fine with the Terminal Clear command not working properly in those cases. Fixing the conpty-specific cases doesn't seem worth it since it can happen off with a native pty too. Isn't conpty meant to be pretending to be a dumb pipe here in the same way as a native pty? I tried doing that same action to run the current Python file on a mac and it will just print a bunch of characters, CR, LF and use the character attribute escape (CSI m). In a similar way it would be lovely if conpty did not reprint the screen when resized unless something actually changed, ie. a line in the viewport is wrapped or will be wrapped. |
ConPTY is pretending to be as close to a dumb pipe as it can. That's the major contention here: there is a 35-year history of win32 console applications that have access to the output buffer. We cannot be a dumb pipe, because that's not something that fits into the "dumb pipe" model. Any concessions we've made in what ConPTY can do and does do are in the pursuit of the broadest possible compatibility. |
Why not to support 2 modes of ConPTY: plain "dumb pipe" and ConPTY with legacy support for |
it seems that: but can we have some workaround to implement buffer clear ? |
@yurenchen000 Are you using Cygwin, MSYS, or MinGW bash? If so, what version of the runtime are you using? Certain versions of the Cygwin runtime delete CSIs. Clearing the buffer works fine from bash, so long as the CSI is not deleted. |
thanks a lot. seems I use lots of cli environment:
can I ignore the CLI environment, |
Unfortunately, I need to reset the cursor position, and I actually just need to do this differently entirely. iTerm actually maintains the last line of the buffer entirely. That's kind of important! Otherwise the prompt just disappears too. They're actually even smarter than that: * https://gitlab.com/gnachman/iterm2/-/issues/1330 * https://gitlab.com/gnachman/iterm2/-/issues/4393 and know where the prompt starts and ends, and keep all of multi-line prompts. That's a very 2023 feature, but we should keep at least one line.
Alright, worked on this a bit in
I mean, this almost certainly will never do the right thing for a full screen app so we may as well do i. because it's easier now.
|
…buffer (#10906) ## Summary of the Pull Request  This adds a new action, `clearBuffer`. It accepts 3 values for the `clear` type: * `"clear": "screen"`: Clear the terminal viewport content. Leaves the scrollback untouched. Moves the cursor row to the top of the viewport (unmodified). * `"clear": "scrollback"`: Clear the scrollback. Leaves the viewport untouched. * `"clear": "all"`: (**default**) Clear the scrollback and the visible viewport. Moves the cursor row to the top of the viewport (unmodified). "Clear Buffer" has also been added to `defaults.json`. ## References * From microsoft/vscode#75141 originally ## PR Checklist * [x] Closes #1193 * [x] Closes #1882 * [x] I work here * [x] Tests added/passed * [ ] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments This is a bit tricky, because we need to plumb it all the way through conpty to clear the buffer. If we don't, then conpty will immediately just redraw the screen. So this sends a signal to the attached conpty, and then waits for conpty to draw the updated, cleared, screen back to us. ## Validation Steps Performed * works for each of the three clear types as expected * tests pass. * works even with `ping -t 8.8.8.8` as you'd hope.
🎉This issue was addressed in #10906, which has now been successfully released as Handy links: |
From @Tyriar in microsoft/vscode#75141
The text was updated successfully, but these errors were encountered: