|
4 | 4 | using System;
|
5 | 5 | using System.Management.Automation;
|
6 | 6 | using System.Threading;
|
| 7 | +using System.Threading.Tasks; |
7 | 8 | using Microsoft.Extensions.Logging;
|
8 | 9 | using Microsoft.PowerShell.EditorServices.Services.PowerShell.Host;
|
9 |
| -using OmniSharp.Extensions.LanguageServer.Protocol.Server; |
10 |
| -using System.Threading.Tasks; |
11 | 10 |
|
12 | 11 | namespace Microsoft.PowerShell.EditorServices.Services.PowerShell.Debugging
|
13 | 12 | {
|
@@ -38,24 +37,30 @@ internal class PowerShellDebugContext : IPowerShellDebugContext
|
38 | 37 | {
|
39 | 38 | private readonly ILogger _logger;
|
40 | 39 |
|
41 |
| - private readonly ILanguageServerFacade _languageServer; |
42 |
| - |
43 | 40 | private readonly PsesInternalHost _psesHost;
|
44 | 41 |
|
45 | 42 | public PowerShellDebugContext(
|
46 | 43 | ILoggerFactory loggerFactory,
|
47 |
| - ILanguageServerFacade languageServer, |
48 | 44 | PsesInternalHost psesHost)
|
49 | 45 | {
|
50 | 46 | _logger = loggerFactory.CreateLogger<PowerShellDebugContext>();
|
51 |
| - _languageServer = languageServer; |
52 | 47 | _psesHost = psesHost;
|
53 | 48 | }
|
54 | 49 |
|
55 | 50 | public bool IsStopped { get; private set; }
|
56 | 51 |
|
| 52 | + /// <summary> |
| 53 | + /// Tracks the state of the LSP debug server (not the PowerShell debugger). |
| 54 | + /// </summary> |
57 | 55 | public bool IsDebugServerActive { get; set; }
|
58 | 56 |
|
| 57 | + /// <summary> |
| 58 | + /// Tracks if the PowerShell session started the debug server itself (true), or if it was |
| 59 | + /// started by an LSP notification (false). Essentially, this marks if we're responsible for |
| 60 | + /// stopping the debug server (and thus need to send a notification to do so). |
| 61 | + /// </summary> |
| 62 | + public bool OwnsDebugServerState { get; set; } |
| 63 | + |
59 | 64 | public DebuggerStopEventArgs LastStopEventArgs { get; private set; }
|
60 | 65 |
|
61 | 66 | public event Action<object, DebuggerStopEventArgs> DebuggerStopped;
|
@@ -165,13 +170,6 @@ public void HandleBreakpointUpdated(BreakpointUpdatedEventArgs breakpointUpdated
|
165 | 170 |
|
166 | 171 | private void RaiseDebuggerStoppedEvent()
|
167 | 172 | {
|
168 |
| - if (!IsDebugServerActive) |
169 |
| - { |
170 |
| - // NOTE: The language server is not necessarily connected, so this must be |
171 |
| - // conditional access. This shows up in unit tests. |
172 |
| - _languageServer?.SendNotification("powerShell/startDebugger"); |
173 |
| - } |
174 |
| - |
175 | 173 | DebuggerStopped?.Invoke(this, LastStopEventArgs);
|
176 | 174 | }
|
177 | 175 |
|
|
0 commit comments