-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show error message when trying to restart an IW debug session (#11739)
Fix #7670
- Loading branch information
1 parent
008f00c
commit 5c5f1a2
Showing
4 changed files
with
58 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/interactive-window/debugger/jupyter/restartNotSupportedController.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { NotebookCell } from 'vscode'; | ||
import { DebugProtocol } from 'vscode-debugprotocol'; | ||
import { IDebuggingDelegate } from '../../../notebooks/debugger/debuggingTypes'; | ||
import { IApplicationShell } from '../../../platform/common/application/types'; | ||
import { DataScience } from '../../../platform/common/utils/localize'; | ||
import { noop } from '../../../platform/common/utils/misc'; | ||
import { IServiceContainer } from '../../../platform/ioc/types'; | ||
import { traceVerbose } from '../../../platform/logging'; | ||
|
||
/** | ||
* Implements the "restart" request. | ||
*/ | ||
export class RestartNotSupportedController implements IDebuggingDelegate { | ||
private readonly applicationShell: IApplicationShell; | ||
|
||
constructor(public readonly debugCell: NotebookCell, serviceContainer: IServiceContainer) { | ||
this.applicationShell = serviceContainer.get<IApplicationShell>(IApplicationShell); | ||
} | ||
|
||
private trace(tag: string, msg: string) { | ||
traceVerbose(`[Debug-IWRestart] ${tag}: ${msg}`); | ||
} | ||
|
||
public async willSendResponse(response: DebugProtocol.Response): Promise<void> { | ||
if (response.command === 'initialize' && response.body) { | ||
(response as DebugProtocol.InitializeResponse).body!.supportsRestartRequest = true; | ||
} | ||
} | ||
|
||
public async willSendRequest(request: DebugProtocol.Request): Promise<undefined | DebugProtocol.Response> { | ||
if (request.command === 'restart') { | ||
this.trace('restart', 'Showing warning for unsupported restart request'); | ||
this.applicationShell.showWarningMessage(DataScience.restartNotSupported()).then(noop, noop); | ||
return { | ||
command: request.command, | ||
request_seq: request.seq, | ||
seq: request.seq, | ||
success: true, | ||
type: 'response' | ||
}; | ||
} | ||
|
||
return undefined; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters