-
Notifications
You must be signed in to change notification settings - Fork 513
Handle clearTerminal message by using vscode clear command #2316
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,11 @@ import * as fs from "fs"; | |
import * as os from "os"; | ||
import * as path from "path"; | ||
import * as vscode from "vscode"; | ||
import { LanguageClient, NotificationType, Position, Range, RequestType } from "vscode-languageclient"; | ||
import { LanguageClient, NotificationType, NotificationType0, | ||
Position, Range, RequestType } from "vscode-languageclient"; | ||
import { IFeature } from "../feature"; | ||
import { Logger } from "../logging"; | ||
import Settings = require("../settings"); | ||
|
||
export interface IExtensionCommand { | ||
name: string; | ||
|
@@ -155,6 +157,9 @@ export const SetStatusBarMessageRequestType = | |
new RequestType<IStatusBarMessageDetails, EditorOperationResponse, void, void>( | ||
"editor/setStatusBarMessage"); | ||
|
||
export const ClearTerminalNotificationType = | ||
new NotificationType0("editor/clearTerminal"); | ||
|
||
export interface ISaveFileDetails { | ||
filePath: string; | ||
newPath?: string; | ||
|
@@ -265,6 +270,16 @@ export class ExtensionCommandsFeature implements IFeature { | |
this.languageClient.onRequest( | ||
SetStatusBarMessageRequestType, | ||
(messageDetails) => this.setStatusBarMessage(messageDetails)); | ||
|
||
this.languageClient.onNotification( | ||
ClearTerminalNotificationType, | ||
() => { | ||
// We check to see if they have TrueClear on. If not, no-op because the | ||
// overriden Clear-Host already calls [System.Console]::Clear() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So glad I cc'd you on that tweet - this is so much better There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't seem to work for me on Windows. Is support for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On Windows the compatibility layer might filter it out or something. I would expect this fix to be in the form of changing how clear acts in conpty to send ED 3 and 2 (i think) to clear the viewport and scrollback when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SeeminglyScience were you trying: Write-Host "`e[3J" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. damn ok - thought that maybe this would be viable but we'll probably have to do what this PR does and use the vscode API. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SeeminglyScience one more thing:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @TylerLeonhardt What about it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got this from one of the Clear issues in the new Windows Terminal. $host.UI.Write( "$([char]27)[3J$([char]27)[2J" ) It mostly works but requires a few tweaks. As is, the command leaves the cursor at the bottom so I expanded on it to reset the cursor to the top: $host.UI.RawUI.CursorPosition = New-Object System.Management.Automation.Host.Coordinates 0,0
$host.UI.Write( "$([char]27)[3J$([char]27)[2J" ) It seems to work better in latest preview. Last time I tested this, I was still having to do manual Remaining issue is the scrollbar doesn't reset so it looks like there is stuff there but there isn't. I still use VS Code's Clear to remove it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah VS Code's Clear is probably the most reliable here but that's great info @dragonwolf83! |
||
if (Settings.load().integratedConsole.useTrueClear) { | ||
vscode.commands.executeCommand("workbench.action.terminal.clear"); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
How about something like
powershell.integrateConsole.clearScrollbackBuffer
. Or slightly more futureproof maybe:"powershell.integratedConsole.clearAction": "scrollback" | "clear"
. Something with the termscrollback
in it, just sinceTrueClear
sounds a bit like a background check or a bad liquor to me.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.
LOL
Ok. I kinda like the clearAction one. Let's go with that
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.
went with
forceClearScrollbackBuffer
because we can't change the behavior of clear-host other than forcing a full clear.