File tree 1 file changed +12
-3
lines changed
src/PowerShellEditorServices/Services/PowerShell/Host
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -666,9 +666,18 @@ private void DoOneRepl(CancellationToken cancellationToken)
666
666
667
667
private string GetPrompt ( CancellationToken cancellationToken )
668
668
{
669
- var command = new PSCommand ( ) . AddCommand ( "prompt" ) ;
670
- IReadOnlyList < string > results = InvokePSCommand < string > ( command , executionOptions : null , cancellationToken ) ;
671
- string prompt = results . Count > 0 ? results [ 0 ] : DefaultPrompt ;
669
+ string prompt = DefaultPrompt ;
670
+ try
671
+ {
672
+ // TODO: Should we cache PSCommands like this as static members?
673
+ var command = new PSCommand ( ) . AddCommand ( "prompt" ) ;
674
+ IReadOnlyList < string > results = InvokePSCommand < string > ( command , executionOptions : null , cancellationToken ) ;
675
+ if ( results . Count > 0 )
676
+ {
677
+ prompt = results [ 0 ] ;
678
+ }
679
+ }
680
+ catch ( CommandNotFoundException ) { } // Use default prompt
672
681
673
682
if ( CurrentRunspace . RunspaceOrigin != RunspaceOrigin . Local )
674
683
{
You can’t perform that action at this time.
0 commit comments