-
Notifications
You must be signed in to change notification settings - Fork 3
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
Removed invalid 'clear' from Runner #46
base: master
Are you sure you want to change the base?
Removed invalid 'clear' from Runner #46
Conversation
36a8363
to
68770bc
Compare
src/extension.ts
Outdated
// Clear the terminal using API Call | ||
await vscode.commands.executeCommand('workbench.action.terminal.clear'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused as to how this works -- how does VSCode know which terminal to use?
Does this work on your machine? 🤔 Can we test this on a normal windows cmd
terminal that doesn't support clear
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, did I mix up the terminal the problem occurs in? Are we talking about the integrated terminal which runs inside VScode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This API-call works for the integrated terminal, platform independent.
As I read in extension.ts#L1343
, the [currently] "active instance" is cleared.
I think this is nicer than something like :
const clearCommand = process.platform === "win32" ? "cls" : "clear";
terminal.sendText(clearCommand);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, but it would really need to be tested. Though even for an external terminal, I'd still love to know how VSCode itself can clear a terminal (since I think it's able to do so)... and hopefully they do have some API for such an action too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, which I don't have any answer for currently 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I looked into the codebase for a few minutes and moved several clearBuffer()
calls down in the abstraction level, but haven't found an ending yet. By time, I'm happy to investigate further:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ITerminalInstance
itself uses two .clearBuffer()
https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts#L1341
=> XTerm and a _process
, one of them should hold the actual commands...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, but I think that's not necessarily the level we'll be able to reach (since that API is most likely private [?]), that's managing the terminal interface via xterm.js
, I'd assume.
Instead, I think we need to search "up" now to see what we can use in the public API that in turn triggers the .clearBuffer()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find a way to use the public API to call .clearBuffer()
. There doesn’t seem to be a way to explicitly set which terminal is active (might be worth raising an issue in the VS Code repo?). The workaround of using terminal.show()
does update onDidChangeActiveTerminal
, but the activeInstance
used in the API call doesn’t update immediately, which causes unexpected behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe VScode Issue #2238507 will gather us more helpful information :)
|
This solution would suggest using Edit: It doesn't seem reliable at all after some testing - even with the sleep. |
Well it's again this variant, I can look into a viable solution with |
Motivation
Removed the invalid call of
clear
for the terminal when running a Effekt-file via the extensionResolves #41
Changes
sendText("clear")
, which caused an error asclear
is not a valid windows commandexecuteCommand('workbench.action.terminal.clear')
, which should perform theclear
operation platform independent