-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Make Clear-Host clear the scrollback buffer too on all platforms #8606
Copy link
Copy link
Closed
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Interactive-Consolethe console experiencethe console experienceWaiting - DotNetCorewaiting on a fix/change in .NETwaiting on a fix/change in .NET
Metadata
Metadata
Assignees
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Interactive-Consolethe console experiencethe console experienceWaiting - DotNetCorewaiting on a fix/change in .NETwaiting on a fix/change in .NET
Type
Projects
Status
Done
Update:
The decision in #8603 to rely on
Console.Clear()amounts to inconsistent behavior across platforms, for no good reason (there's no native behavior that needs to be emulated; native behavior, if desired, is accessible via the externalclearutility).If there's consensus that the desired behavior is to consistently clear the screen and the scrollback buffer on all platforms, we have two options:
Wait for
Console.Clear()to be fixed, if ever - see https://github.com/dotnet/corefx/issues/34463Roll our own solution in PowerShell [in the meantime].
The original proposal below was written under the assumption that platform-dependent behavior was intended, and therefore suggested an opt-in mechanism.
Summary of the new feature/enhancement
Implement a switch named
-Allto directClear-Hostto clear not only the current screen of terminal (console) hosts but to clear the scrollback buffer (the output history) as well.Clear-Hostnow uses[Console]::Clear()(see #8603), which results in platform-specific behavior:That is, also clearing the scrollback buffer is invariably implied on Windows, whereas it is currently unavailable on Unix-like platforms.
Implementing
-Allwould allow users to at least opt into a consistent cross-platform experience, e.g. via a user-defined function such asfunction clsa { Clear-Host -All }.Note: As before, this means that in the Windows console you do not have the option to selectively clear the current screen only, without erasing the scrollback buffer.
Proposed technical implementation details (optional)
If
-Allis specified:$host.ui.Write("`e[3J")after[Console]::Clear()to also clear the scrollback buffer.