3
3
4
4
using System ;
5
5
using System . Collections . Generic ;
6
- using System . IO ;
7
6
using System . Threading ;
8
7
using System . Threading . Tasks ;
9
8
using MediatR ;
10
9
using Microsoft . Extensions . Logging ;
11
10
using Microsoft . PowerShell . EditorServices . Logging ;
12
11
using Microsoft . PowerShell . EditorServices . Services ;
13
12
using Microsoft . PowerShell . EditorServices . Services . Configuration ;
14
- using Microsoft . PowerShell . EditorServices . Services . Extension ;
15
- using Microsoft . PowerShell . EditorServices . Services . PowerShell . Host ;
16
13
using Newtonsoft . Json . Linq ;
17
14
using OmniSharp . Extensions . LanguageServer . Protocol . Models ;
18
15
using OmniSharp . Extensions . LanguageServer . Protocol . Server ;
@@ -26,27 +23,19 @@ internal class PsesConfigurationHandler : DidChangeConfigurationHandlerBase
26
23
private readonly ILogger _logger ;
27
24
private readonly WorkspaceService _workspaceService ;
28
25
private readonly ConfigurationService _configurationService ;
29
- private readonly ExtensionService _extensionService ;
30
- private readonly PsesInternalHost _psesHost ;
31
26
private readonly ILanguageServerFacade _languageServer ;
32
- private bool _profilesLoaded ;
33
- private bool _cwdSet ;
34
27
35
28
public PsesConfigurationHandler (
36
29
ILoggerFactory factory ,
37
30
WorkspaceService workspaceService ,
38
31
AnalysisService analysisService ,
39
32
ConfigurationService configurationService ,
40
- ILanguageServerFacade languageServer ,
41
- ExtensionService extensionService ,
42
- PsesInternalHost psesHost )
33
+ ILanguageServerFacade languageServer )
43
34
{
44
35
_logger = factory . CreateLogger < PsesConfigurationHandler > ( ) ;
45
36
_workspaceService = workspaceService ;
46
37
_configurationService = configurationService ;
47
38
_languageServer = languageServer ;
48
- _extensionService = extensionService ;
49
- _psesHost = psesHost ;
50
39
51
40
ConfigurationUpdated += analysisService . OnConfigurationUpdated ;
52
41
}
@@ -63,7 +52,6 @@ public override async Task<Unit> Handle(DidChangeConfigurationParams request, Ca
63
52
64
53
SendFeatureChangesTelemetry ( incomingSettings ) ;
65
54
66
- bool profileLoadingPreviouslyEnabled = _configurationService . CurrentSettings . EnableProfileLoading ;
67
55
bool oldScriptAnalysisEnabled = _configurationService . CurrentSettings . ScriptAnalysis . Enable ;
68
56
string oldScriptAnalysisSettingsPath = _configurationService . CurrentSettings . ScriptAnalysis ? . SettingsPath ;
69
57
@@ -72,66 +60,6 @@ public override async Task<Unit> Handle(DidChangeConfigurationParams request, Ca
72
60
_workspaceService . WorkspacePath ,
73
61
_logger ) ;
74
62
75
- // We need to load the profiles if:
76
- // - Profile loading is configured, AND
77
- // - Profiles haven't been loaded before, OR
78
- // - The profile loading configuration just changed
79
- bool loadProfiles = _configurationService . CurrentSettings . EnableProfileLoading
80
- && ( ! _profilesLoaded || ! profileLoadingPreviouslyEnabled ) ;
81
-
82
- if ( ! _psesHost . IsRunning )
83
- {
84
- _logger . LogTrace ( "Starting command loop" ) ;
85
-
86
- if ( loadProfiles )
87
- {
88
- _logger . LogTrace ( "Loading profiles..." ) ;
89
- }
90
-
91
- await _psesHost . TryStartAsync ( new HostStartOptions { LoadProfiles = loadProfiles } , CancellationToken . None ) . ConfigureAwait ( false ) ;
92
-
93
- if ( loadProfiles )
94
- {
95
- _profilesLoaded = true ;
96
- _logger . LogTrace ( "Loaded!" ) ;
97
- }
98
- }
99
-
100
- // TODO: Load profiles when the host is already running? Note that this might mess up
101
- // the ordering and require the foreground.
102
- if ( ! _cwdSet )
103
- {
104
- if ( ! string . IsNullOrEmpty ( _configurationService . CurrentSettings . Cwd )
105
- && Directory . Exists ( _configurationService . CurrentSettings . Cwd ) )
106
- {
107
- _logger . LogTrace ( $ "Setting CWD (from config) to { _configurationService . CurrentSettings . Cwd } ") ;
108
- await _psesHost . SetInitialWorkingDirectoryAsync (
109
- _configurationService . CurrentSettings . Cwd ,
110
- CancellationToken . None ) . ConfigureAwait ( false ) ;
111
- }
112
- else if ( _workspaceService . WorkspacePath is not null
113
- && Directory . Exists ( _workspaceService . WorkspacePath ) )
114
- {
115
- _logger . LogTrace ( $ "Setting CWD (from workspace) to { _workspaceService . WorkspacePath } ") ;
116
- await _psesHost . SetInitialWorkingDirectoryAsync (
117
- _workspaceService . WorkspacePath ,
118
- CancellationToken . None ) . ConfigureAwait ( false ) ;
119
- }
120
- else
121
- {
122
- _logger . LogTrace ( "Tried to set CWD but in bad state" ) ;
123
- }
124
-
125
- _cwdSet = true ;
126
- }
127
-
128
- // This is another place we call this to setup $psEditor, which really needs to be done
129
- // _before_ profiles. In current testing, this has already been done by the call to
130
- // InitializeAsync when the ExtensionService class is injected.
131
- //
132
- // TODO: Remove this.
133
- await _extensionService . InitializeAsync ( ) . ConfigureAwait ( false ) ;
134
-
135
63
// Run any events subscribed to configuration updates
136
64
_logger . LogTrace ( "Running configuration update event handlers" ) ;
137
65
ConfigurationUpdated ? . Invoke ( this , _configurationService . CurrentSettings ) ;
0 commit comments