Skip to content
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

"Terminal: Clear" not working as desired #75141

Closed
vivekmalhotra opened this issue Jun 8, 2019 · 83 comments · Fixed by #184734
Closed

"Terminal: Clear" not working as desired #75141

vivekmalhotra opened this issue Jun 8, 2019 · 83 comments · Fixed by #184734
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug terminal-conpty Integrated terminal issues related to the ConPTY backend upstream Issue identified as 'upstream' component related (exists outside of VS Code) upstream-issue-fixed The underlying upstream issue has been fixed upstream-issue-linked This is an upstream issue that has been reported upstream windows VS Code on Windows issues

Comments

@vivekmalhotra
Copy link

Steps to Reproduce:

  1. Run a python file using command palette >Python: Run file in terminal window
  2. Terminal shows the output. Now, clear the terminal using command palette >Terminal: Clear
  3. Terminal gets clear now. Run the file again in the terminal >Python: Run file in terminal window
  4. Here is where issue shows up - the terminal still shows all the previous outputs from before the last clear command. IMO, desired should be that terminal should not show any previously cleared outputs.
  5. Attached below is a gif of the screen reproducing & visualizing this issue

Screenshot PC - 072 - 2019_06_08_1016

Does this issue occur when all extensions are disabled?:
Yes, the issue reoccurs. (Note: All except the "Python" extension were disabled. Python extension is needed to run the python file in terminal.

I had also posted in Super User forum thinking this was some issue with my system. And then I tried it on a clean build of VS code and it got repeated. Hence, I decided to post it as a bug.

Link to Super User forum question

VS Code version: Code - Insiders 1.36.0-insider (c089daa, 2019-06-07T05:19:15.188Z)
OS version: Windows_NT x64 10.0.18362

System Info
Item Value
CPUs Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz (12 x 3696)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.68GB (7.71GB free)
Process Argv
Screen Reader no
VM 0%
Extensions (1)
Extension Author (truncated) Version
python ms- 2019.5.18875
@vscodebot
Copy link

vscodebot bot commented Jun 8, 2019

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@vscodebot vscodebot bot added the terminal Integrated terminal issues label Jun 8, 2019
@Tyriar
Copy link
Member

Tyriar commented Jun 8, 2019

@vivekmalhotra this is happening because Terminal: Clear tells the frontend (the thing rendering everything) to clear, but the way that the conpty backend works is it will sometimes reprint what it thinks should be visible. Since it doesn't know about our clear it reprints the unwanted output, this doesn't happen on a regular linux/mac backend that conpty is trying to emulate.

@zadjii-msft is there anything that can be done here to tell conpty to not reprint the screen? I suspect python.exe does not enter alt mode so I'm not sure why a reprint is necessary.

@Tyriar Tyriar added terminal-conpty Integrated terminal issues related to the ConPTY backend info-needed Issue requires more information from poster labels Jun 8, 2019
@zadjii-msft
Copy link
Member

Hmm. That might not be a scenario that works for us right now. We might need to add an extra input sequence/signal to tell conpty to clear the buffer.

I am a little curious why the whole buffer got repainted, that does seem like a bug. However, since conpty does think that all that text is still there (because its buffer wasn't cleared, only the frontend buffer was), it might get more confused by not repainting the entire thing.

@Tyriar
Copy link
Member

Tyriar commented Jun 10, 2019

@zadjii-msft might be better to fix the bug if there is one, rather than add an explicit manually clear the buffer sequence that only works on conpty.

@vscodebot
Copy link

vscodebot bot commented Jun 17, 2019

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@vivekmalhotra
Copy link
Author

vivekmalhotra commented Jun 19, 2019

@zadjii-msft @Tyriar
I can confirm that the issue is still prevalent in the latest insiders build.
Unsure on how to re-open this issue?

@zadjii-msft
Copy link
Member

This is a bug that's external to VsCode. It'll be fixed by work on the ConPTY API that'll be tracked by microsoft/terminal#1193.

@vivekmalhotra
Copy link
Author

This is a bug that's external to VsCode. It'll be fixed by work on the ConPTY API that'll be tracked by microsoft/terminal#1193.

Thanks for the reply, Mike

@Tyriar Tyriar reopened this Jun 19, 2019
@Tyriar
Copy link
Member

Tyriar commented Jun 19, 2019

@vivekmalhotra the bot closed it because of the needs more info label, reopened.

@Tyriar Tyriar added upstream Issue identified as 'upstream' component related (exists outside of VS Code) and removed info-needed Issue requires more information from poster labels Jun 19, 2019
@Tyriar Tyriar added this to the Backlog milestone Jun 19, 2019
@ghost
Copy link

ghost commented Jun 26, 2019

Terminal clear

I run npm in terminal,then end it with "Ctrl + C" , useing code clear and get result as left(I have click enter several times),useing "ctrl + shift + p" and "terminal clear" get result as right,it clear all and terminal crashed.

terminal will back to line 1 and enterable but not clear character。

用了clear命令后,terminal返回第一行并且可编辑,但是并没有清理界面字符,使用 控制中心的Terminal clear 指令后可以清理,但是terminal崩溃了

image

@solacens
Copy link

solacens commented Jul 3, 2019

So who should be fixing the issue now? VS Code here or Windows Terminal? 😢

Any workaround at the moment? This issue is quite annoying.

@ghost
Copy link

ghost commented Jul 3, 2019

No debounce,Push 1s Enter,it still effective,more than 1s

@zadjii-msft
Copy link
Member

@solacens

It'll be fixed by work on the ConPTY API that'll be tracked by microsoft/terminal#1193.

@solacens
Copy link

solacens commented Jul 8, 2019

@zadjii-msft Thanks for the information. I will keep track on the related issue.

@Tyriar
Copy link
Member

Tyriar commented Jun 9, 2023

@GearTheWorld the milestone of the issue which is the month in which the work is done. It'll get released in early July.

@vivekmalhotra
Copy link
Author

@GearTheWorld the milestone of the issue which is the month in which the work is done. It'll get released in early July.

Great to hear this is now fixed - thanks @Tyriar! Coincidentally, the issue got fixed on June 9th, exactly 4 years after it was first created. Time flies... 😊

@rzhao271 rzhao271 added the verified Verification succeeded label Jun 28, 2023
@rzhao271
Copy link
Contributor

I still see a lot of whitespace in the terminal:

Run Python file in terminal, then clear, then running it again shows a lot of whitespace where there shouldn't be any

@rzhao271 rzhao271 reopened this Jun 28, 2023
@rzhao271 rzhao271 added verification-found Issue verification failed and removed verified Verification succeeded labels Jun 28, 2023
@VSCodeTriageBot VSCodeTriageBot removed the insiders-released Patch has been released in VS Code Insiders label Jun 28, 2023
@heartacker
Copy link
Contributor

same here

@Tyriar
Copy link
Member

Tyriar commented Jun 29, 2023

@zadjii-msft is this behaving as expected? Does calling into the conpty clear API not reset its internal buffer cursor position to 0,0?

@Tyriar Tyriar modified the milestones: June 2023, July 2023 Jun 29, 2023
@Tyriar Tyriar removed the verification-found Issue verification failed label Jun 29, 2023
@Svish
Copy link

Svish commented Jun 29, 2023

VS Code, on Windows, with regular cmd terminal, when i run clear, it does scroll the buffer so my cursor is at position 0,0, but that's not what clear is supposed to do. It's supposed to clear the terminal, i.e. empty the buffer completely so that I'm at a fresh start.

I use it frequently in the command-line when dealing with commands that spit out a lot of text or errors. Sometimes it's difficult to see where the output from one command ends and the next begins, and in those cases it's super handy to just run clear and empty the buffer completely, so that the only output on the screen will be from the command I'm about to run.

This doesn't work at all in VS Code currently. Running clear simply scrolls the buffer up a bit, so it looks empty, but when I run my next command outputting a bunch of text, and then try to scroll up to find the beginning, I eventually get to old output, making it a lot harder. Only workaround is to exit the terminal and open a new one, which is a hassle and should be uneccessary.

clear should clear.

@Tyriar
Copy link
Member

Tyriar commented Jun 29, 2023

@Svish this is talking about the Terminal: Clear VS Code command, not the clear shell command. This is what you're talking about xtermjs/xterm.js#1727

@Pieras2
Copy link

Pieras2 commented Jun 29, 2023

I see many comments but for me it started to work weeks ago. I use gitbash in vac and "clear" works now as a charm

@Tyriar Tyriar modified the milestones: July 2023, Backlog Jul 24, 2023
@VLFrosttide
Copy link

Still having an issue of the terminal clearing, then it skiping lines when I start writing , same as this guy here
#109012
Clearing it with the workbench.action.terminal.clear.

@tungrix
Copy link

tungrix commented Sep 18, 2023

Ctrl + K seems work for me instead of typing clear in terminal.

@Tyriar
Copy link
Member

Tyriar commented Dec 7, 2023

Closing this as it was fixed on our end with #184734, you may not get the fix until a future Windows update unfortunately

@Tyriar Tyriar closed this as completed Dec 7, 2023
@mehedihasanziku
Copy link

mehedihasanziku commented Jan 8, 2024

Closing this as it was fixed on our end with #184734, you may not get the fix until a future Windows update unfortunately

@Tyriar This answer doesn't help us, anyway to force update? which package from windows need to be updated?
node-pty we need update our node package? Please refer us window update link

Update: I think this way it's working

https://github.com/microsoft/terminal/releases - Update Terminal to latest, prefer to use only Latest not Pre-release

Assets > .msixbundle format and install that, that's it.

It didn't work in first attempt of vscode restart, but after reset this setting both here, probably did the work, maybe it will work after pc restart also.

image

image

@github-actions github-actions bot locked and limited conversation to collaborators Jan 22, 2024
@Tyriar
Copy link
Member

Tyriar commented Jan 30, 2024

This answer doesn't help us, anyway to force update? which package from windows need to be updated?
node-pty we need update our node package?

@mehedihasanziku I'm not sure the version exactly but it's not a package you can install independently but Windows itself, you might be able to find the version by following links to the microsoft/terminal repo.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug terminal-conpty Integrated terminal issues related to the ConPTY backend upstream Issue identified as 'upstream' component related (exists outside of VS Code) upstream-issue-fixed The underlying upstream issue has been fixed upstream-issue-linked This is an upstream issue that has been reported upstream windows VS Code on Windows issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.