14
14
using Microsoft . PowerShell . EditorServices . Services . PowerShell . Debugging ;
15
15
using Microsoft . PowerShell . EditorServices . Services . PowerShell . Host ;
16
16
using Microsoft . PowerShell . EditorServices . Services . PowerShell . Runspace ;
17
+ using Microsoft . PowerShell . EditorServices . Utility ;
17
18
using OmniSharp . Extensions . DebugAdapter . Server ;
18
19
using OmniSharp . Extensions . LanguageServer . Server ;
19
20
@@ -27,7 +28,7 @@ internal class PsesDebugServer : IDisposable
27
28
/// <summary>
28
29
/// This is a bool but must be an int, since Interlocked.Exchange can't handle a bool
29
30
/// </summary>
30
- private static int s_hasRunPsrlStaticCtor = 0 ;
31
+ private static readonly IdempotentLatch s_psrlCtorLatch = new ( ) ;
31
32
32
33
private static readonly Lazy < CmdletInfo > s_lazyInvokeReadLineConstructorCmdletInfo = new Lazy < CmdletInfo > ( ( ) =>
33
34
{
@@ -79,22 +80,6 @@ public async Task StartAsync()
79
80
_debugContext = ServiceProvider . GetService < PsesInternalHost > ( ) . DebugContext ;
80
81
_debugContext . IsDebugServerActive = true ;
81
82
82
- /*
83
- // Needed to make sure PSReadLine's static properties are initialized in the pipeline thread.
84
- // This is only needed for Temp sessions who only have a debug server.
85
- if (_usePSReadLine && _useTempSession && Interlocked.Exchange(ref s_hasRunPsrlStaticCtor, 1) == 0)
86
- {
87
- // This must be run synchronously to ensure debugging works
88
- _executionService
89
- .ExecuteDelegateAsync((cancellationToken) =>
90
- {
91
- // Is this needed now that we do things the cool way??
92
- }, "PSRL static constructor execution", CancellationToken.None)
93
- .GetAwaiter()
94
- .GetResult();
95
- }
96
- */
97
-
98
83
options
99
84
. WithInput ( _inputStream )
100
85
. WithOutput ( _outputStream )
0 commit comments