From b8a4ce6833ba8f27a2d97e95d30b8457b1a1fd1d Mon Sep 17 00:00:00 2001 From: David Kutugata Date: Thu, 31 Oct 2019 11:00:14 -0700 Subject: [PATCH 1/2] clear execution count of all cells when user presses 'Clear All Output' --- news/2 Fixes/7853.md | 1 + src/datascience-ui/interactive-common/mainStateController.ts | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 news/2 Fixes/7853.md diff --git a/news/2 Fixes/7853.md b/news/2 Fixes/7853.md new file mode 100644 index 000000000000..41bec365dc14 --- /dev/null +++ b/news/2 Fixes/7853.md @@ -0,0 +1 @@ +'Clear All Output' now deletes execution count for all cells. diff --git a/src/datascience-ui/interactive-common/mainStateController.ts b/src/datascience-ui/interactive-common/mainStateController.ts index c17515b9e5b0..1a9c35521fa2 100644 --- a/src/datascience-ui/interactive-common/mainStateController.ts +++ b/src/datascience-ui/interactive-common/mainStateController.ts @@ -401,6 +401,9 @@ export class MainStateController implements IMessageHandler { const newList = this.pendingState.cellVMs.map(cellVM => { return immutable.updateIn(cellVM, ['cell', 'data', 'outputs'], () => []); }); + newList.forEach(cellVM => { + cellVM.cell.data.execution_count = null; + }); this.setState({ cellVMs: newList }); From 878085cf80eb3479e657345afd57eb477913514c Mon Sep 17 00:00:00 2001 From: David Kutugata Date: Thu, 31 Oct 2019 15:14:08 -0700 Subject: [PATCH 2/2] remove execution count with immutable --- .../interactive-common/mainStateController.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/datascience-ui/interactive-common/mainStateController.ts b/src/datascience-ui/interactive-common/mainStateController.ts index 1a9c35521fa2..b115b25acbd9 100644 --- a/src/datascience-ui/interactive-common/mainStateController.ts +++ b/src/datascience-ui/interactive-common/mainStateController.ts @@ -399,10 +399,8 @@ export class MainStateController implements IMessageHandler { public clearAllOutputs = () => { const newList = this.pendingState.cellVMs.map(cellVM => { - return immutable.updateIn(cellVM, ['cell', 'data', 'outputs'], () => []); - }); - newList.forEach(cellVM => { - cellVM.cell.data.execution_count = null; + const updatedVm = immutable.updateIn(cellVM, ['cell', 'data', 'outputs'], () => []); + return immutable.removeIn(updatedVm, ['cell', 'data', 'execution_count']); }); this.setState({ cellVMs: newList