Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/9991.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clear variables in notebooks and interactive-window when restarting.
7 changes: 6 additions & 1 deletion src/client/datascience/interactive-ipynb/nativeEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,12 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
return this.setDirty();
}

protected addSysInfo(_reason: SysInfoReason): Promise<void> {
protected addSysInfo(reason: SysInfoReason): Promise<void> {
// We need to send a message when restarting
if (reason === SysInfoReason.Restart || reason === SysInfoReason.New) {
this.postMessage(InteractiveWindowMessages.RestartKernel).ignoreErrors();
}

// These are not supported.
return Promise.resolve();
}
Expand Down
34 changes: 15 additions & 19 deletions src/datascience-ui/interactive-common/redux/reducers/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,25 +118,21 @@ function handleResponse(arg: VariableReducerArg<IJupyterVariablesResponse>): IVa
}

function handleRestarted(arg: VariableReducerArg): IVariableState {
// If the variables are visible, refresh them
if (arg.prevState.visible) {
const result = handleRequest({
...arg,
payload: {
executionCount: 0,
sortColumn: 'name',
sortAscending: true,
startIndex: 0,
pageSize: arg.prevState.pageSize
}
});
return {
...result,
currentExecutionCount: 0,
variables: []
};
}
return arg.prevState;
const result = handleRequest({
...arg,
payload: {
executionCount: 0,
sortColumn: 'name',
sortAscending: true,
startIndex: 0,
pageSize: arg.prevState.pageSize
}
});
return {
...result,
currentExecutionCount: 0,
variables: []
};
}

function handleFinishCell(arg: VariableReducerArg<ICell>): IVariableState {
Expand Down