Skip to content

clear execution count of all cells when user presses 'Clear All Output' #8318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/7853.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
'Clear All Output' now deletes execution count for all cells.
3 changes: 3 additions & 0 deletions src/datascience-ui/interactive-common/mainStateController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't Don just add this? Also this would need to use the immutable functions.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah or make a copy of all of the cells. Something like so:

const newList = this.pendingState.cellVMs.map(cellVM => {
return {...celVM, cell: {...cellVM.cell, data: {...cellVM.cell.data, execution_count: null, outputs: []}}};
})

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meaning you should set the execution count at the same time you clear the outputs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't Don just add this? Also this would need to use the immutable functions.

Yes & no. I started working on this (forgot to assign to myself). When I went to assign it, @DavidKutu had it.

Here is the review where don already added this:
https://github.com/microsoft/vscode-python/pull/8315/files

Oops, used the same branch of code.
Didn't mean to work on it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @DavidKutu

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you review again?

});
this.setState({
cellVMs: newList
});
Expand Down