Skip to content

Commit ed09569

Browse files
authored
Port variable restart fix (#9938)
* Fix variable explorer when restarting a kernel (#9931) * Make sure to clear variable list on reset * Add news entry * Update changelog * Update changelog
1 parent d022524 commit ed09569

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747

4848
### Fixes
4949

50+
1. Make sure to clear variable list on restart kernel.
51+
([#9740](https://github.com/Microsoft/vscode-python/issues/9740))
5052
1. Use the autoStart server when available.
5153
([#9926](https://github.com/Microsoft/vscode-python/issues/9926))
5254
1. Removed unnecessary warning when executing cells that use Scrapbook,
@@ -4966,4 +4968,4 @@ the following people who contributed code:
49664968
* Added ability to view global variables, arguments, add and remove break points
49674969

49684970
## Version 0.0.3
4969-
* Added support for debugging using PDB
4971+
* Added support for debugging using PDB

src/datascience-ui/interactive-common/redux/reducers/variables.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type VariableReducerFunc<T> = ReducerFunc<IVariableState, IncomingMessageActions
2222
type VariableReducerArg<T = never | undefined> = ReducerArg<IVariableState, IncomingMessageActions, T>;
2323

2424
function handleRequest(arg: VariableReducerArg<IJupyterVariablesRequest>): IVariableState {
25-
const newExecutionCount = arg.payload.executionCount ? arg.payload.executionCount : arg.prevState.currentExecutionCount;
25+
const newExecutionCount = arg.payload.executionCount !== undefined ? arg.payload.executionCount : arg.prevState.currentExecutionCount;
2626
arg.queueAction(
2727
createPostableAction(InteractiveWindowMessages.GetVariablesRequest, {
2828
executionCount: newExecutionCount,
@@ -108,7 +108,12 @@ function handleResponse(arg: VariableReducerArg<IJupyterVariablesResponse>): IVa
108108
function handleRestarted(arg: VariableReducerArg): IVariableState {
109109
// If the variables are visible, refresh them
110110
if (arg.prevState.visible) {
111-
return handleRequest({ ...arg, payload: { executionCount: 0, sortColumn: 'name', sortAscending: true, startIndex: 0, pageSize: arg.prevState.pageSize } });
111+
const result = handleRequest({ ...arg, payload: { executionCount: 0, sortColumn: 'name', sortAscending: true, startIndex: 0, pageSize: arg.prevState.pageSize } });
112+
return {
113+
...result,
114+
currentExecutionCount: 0,
115+
variables: []
116+
};
112117
}
113118
return arg.prevState;
114119
}

0 commit comments

Comments
 (0)