-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clear the terminal via the LSP (#1108)
* Clear the terminal via the LSP * use actual Clear-Host impl * add clear for only Windows
- Loading branch information
1 parent
3591ee1
commit e813fbd
Showing
6 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
module/PowerShellEditorServices/Commands/Public/Clear-Host.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# Copyright (c) Microsoft. All rights reserved. | ||
# Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
# | ||
|
||
Microsoft.PowerShell.Management\Get-Item function:Clear-Host | Microsoft.PowerShell.Management\Set-Item function:__clearhost | ||
|
||
function Clear-Host { | ||
[Alias('cls')] | ||
param() | ||
|
||
__clearhost | ||
$psEditor.Window.Terminal.Clear() | ||
} | ||
|
||
if (!$IsMacOS -or $IsLinux) { | ||
Set-Alias -Name clear -Value Clear-Host | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/PowerShellEditorServices/Services/PowerShellContext/Extensions/EditorTerminal.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// | ||
|
||
namespace Microsoft.PowerShell.EditorServices.Services.PowerShellContext | ||
{ | ||
/// <summary> | ||
/// Provides a PowerShell-facing API which allows scripts to | ||
/// interact with the editor's terminal. | ||
/// </summary> | ||
public class EditorTerminal | ||
{ | ||
#region Private Fields | ||
|
||
private readonly IEditorOperations editorOperations; | ||
|
||
#endregion | ||
|
||
#region Constructors | ||
|
||
/// <summary> | ||
/// Creates a new instance of the EditorTerminal class. | ||
/// </summary> | ||
/// <param name="editorOperations">An IEditorOperations implementation which handles operations in the host editor.</param> | ||
internal EditorTerminal(IEditorOperations editorOperations) | ||
{ | ||
this.editorOperations = editorOperations; | ||
} | ||
|
||
#endregion | ||
|
||
#region Public Methods | ||
|
||
/// <summary> | ||
/// Triggers to the editor to clear the terminal. | ||
/// </summary> | ||
public void Clear() | ||
{ | ||
this.editorOperations.ClearTerminal(); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters