14
14
using OmniSharp . Extensions . LanguageServer . Protocol . Client . Capabilities ;
15
15
using OmniSharp . Extensions . LanguageServer . Protocol . Models ;
16
16
using OmniSharp . Extensions . LanguageServer . Protocol . Workspace ;
17
+ using System . IO ;
17
18
18
19
namespace Microsoft . PowerShell . EditorServices . Handlers
19
20
{
@@ -26,6 +27,7 @@ internal class PsesConfigurationHandler : IDidChangeConfigurationHandler
26
27
private DidChangeConfigurationCapability _capability ;
27
28
private bool _profilesLoaded ;
28
29
private bool _consoleReplStarted ;
30
+ private bool _cwdSet ;
29
31
30
32
public PsesConfigurationHandler (
31
33
ILoggerFactory factory ,
@@ -66,6 +68,26 @@ public async Task<Unit> Handle(DidChangeConfigurationParams request, Cancellatio
66
68
_workspaceService . WorkspacePath ,
67
69
_logger ) ;
68
70
71
+ if ( ! this . _cwdSet )
72
+ {
73
+ if ( ! string . IsNullOrEmpty ( _configurationService . CurrentSettings . Cwd )
74
+ && Directory . Exists ( _configurationService . CurrentSettings . Cwd ) )
75
+ {
76
+ await _powerShellContextService . SetWorkingDirectoryAsync (
77
+ _configurationService . CurrentSettings . Cwd ,
78
+ isPathAlreadyEscaped : false ) . ConfigureAwait ( false ) ;
79
+
80
+ } else if ( _workspaceService . WorkspacePath != null
81
+ && Directory . Exists ( _workspaceService . WorkspacePath ) )
82
+ {
83
+ await _powerShellContextService . SetWorkingDirectoryAsync (
84
+ _workspaceService . WorkspacePath ,
85
+ isPathAlreadyEscaped : false ) . ConfigureAwait ( false ) ;
86
+ }
87
+
88
+ this . _cwdSet = true ;
89
+ }
90
+
69
91
if ( ! this . _profilesLoaded &&
70
92
_configurationService . CurrentSettings . EnableProfileLoading &&
71
93
oldLoadProfiles != _configurationService . CurrentSettings . EnableProfileLoading )
0 commit comments