File tree 3 files changed +10
-3
lines changed
src/PowerShellEditorServices/Services/PowerShellContext
3 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -124,7 +124,8 @@ private async Task CheckPackageManagement()
124
124
{
125
125
WriteInputToHost = true ,
126
126
WriteErrorsToHost = true ,
127
- WriteOutputToHost = true
127
+ WriteOutputToHost = true ,
128
+ InputString = "Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber"
128
129
} ) . ConfigureAwait ( false ) ;
129
130
130
131
// There were errors installing PackageManagement.
Original file line number Diff line number Diff line change @@ -597,7 +597,7 @@ public async Task<IEnumerable<TResult>> ExecuteCommandAsync<TResult>(
597
597
// cancelled prompt when it's called again.
598
598
if ( executionOptions . AddToHistory )
599
599
{
600
- this . PromptContext . AddToHistory ( psCommand . Commands [ 0 ] . CommandText ) ;
600
+ this . PromptContext . AddToHistory ( executionOptions . InputString ?? psCommand . Commands [ 0 ] . CommandText ) ;
601
601
}
602
602
603
603
bool hadErrors = false ;
@@ -686,7 +686,7 @@ public async Task<IEnumerable<TResult>> ExecuteCommandAsync<TResult>(
686
686
if ( executionOptions . WriteInputToHost )
687
687
{
688
688
this . WriteOutput (
689
- psCommand . Commands [ 0 ] . CommandText ,
689
+ executionOptions . InputString ?? psCommand . Commands [ 0 ] . CommandText ,
690
690
includeNewLine : true ) ;
691
691
}
692
692
Original file line number Diff line number Diff line change @@ -46,6 +46,12 @@ internal class ExecutionOptions
46
46
/// </summary>
47
47
public bool WriteInputToHost { get ; set ; }
48
48
49
+ /// <summary>
50
+ /// If this is set, we will use this string for history and writing to the host
51
+ /// instead of grabbing the command from the PSCommand.
52
+ /// </summary>
53
+ public string InputString { get ; set ; }
54
+
49
55
/// <summary>
50
56
/// Gets or sets a value indicating whether the command to
51
57
/// be executed is a console input prompt, such as the
You can’t perform that action at this time.
0 commit comments