Skip to content

Commit 1f39fe2

Browse files
authored
Disable run/interrupt/restart buttons when switching kernels (#10291)
1 parent 4883cff commit 1f39fe2

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

news/2 Fixes/9935.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Switching kernels should disable the run/interrupt/restart buttons.

src/client/datascience/interactive-common/interactiveBase.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,12 @@ export abstract class InteractiveBase extends WebViewHost<IInteractiveWindowMapp
14801480
if (!this._notebook) {
14811481
return;
14821482
}
1483-
await this.commandManager.executeCommand(Commands.SwitchJupyterKernel, this._notebook);
1483+
try {
1484+
this.startProgress();
1485+
await this.commandManager.executeCommand(Commands.SwitchJupyterKernel, this._notebook);
1486+
} finally {
1487+
this.stopProgress();
1488+
}
14841489
}
14851490
private async kernelChangeHandler(kernel: IJupyterKernelSpec | LiveKernelModel) {
14861491
// Check if we are changing to LiveKernelModel

src/datascience-ui/native-editor/nativeCell.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ interface INativeCellBaseProps {
4343
editorOptions: monacoEditor.editor.IEditorOptions;
4444
themeMatplotlibPlots: boolean | undefined;
4545
focusPending: number;
46+
busy: boolean;
4647
}
4748

4849
type INativeCellProps = INativeCellBaseProps & typeof actionCreators;
@@ -567,6 +568,7 @@ export class NativeCell extends React.Component<INativeCellProps> {
567568
onClick={runCell}
568569
tooltip={getLocString('DataScience.runCell', 'Run cell')}
569570
hidden={this.isMarkdownCell()}
571+
disabled={this.props.busy}
570572
>
571573
<Image baseTheme={this.props.baseTheme} class="image-button-image" image={ImageName.Run} />
572574
</ImageButton>

src/datascience-ui/native-editor/nativeEditor.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ ${buildSettingsCss(this.props.settings)}`}</style>
477477
themeMatplotlibPlots={this.props.settings.themeMatplotlibPlots}
478478
// Focus pending does not apply to native editor.
479479
focusPending={0}
480+
busy={this.props.busy}
480481
/>
481482
</ErrorBoundary>
482483
{lastLine}

0 commit comments

Comments
 (0)