Ensure notebook execution count is cleared only when necessary
parent
9324d6c826
commit
2a3b61a82c
|
@ -123,6 +123,7 @@ function trackAndUpdateCellMetadata(notebook: NotebookDocument, updates: { cell:
|
|||
promise.then(clean, clean);
|
||||
}
|
||||
|
||||
const pendingCellUpdates = new WeakSet<NotebookCell>();
|
||||
function onDidChangeNotebookCells(e: NotebookDocumentChangeEventEx) {
|
||||
if (!isSupportedNotebook(e.notebook)) {
|
||||
return;
|
||||
|
@ -155,11 +156,15 @@ function onDidChangeNotebookCells(e: NotebookDocumentChangeEventEx) {
|
|||
// Thus this is a change in metadata, which we will need to update in the model.
|
||||
metadata.execution_count = null;
|
||||
metadataUpdated = true;
|
||||
// Note: We will get another event for this, see below for the check.
|
||||
// track the fact that we're expecting an update for this cell.
|
||||
pendingCellUpdates.add(e.cell);
|
||||
} else if ((!e.executionSummary || (!e.executionSummary?.executionOrder && !e.executionSummary?.success && !e.executionSummary?.timing))
|
||||
&& !e.metadata && !e.outputs && currentMetadata.execution_count) {
|
||||
// This is a result of the previous cell being cleared.
|
||||
&& !e.metadata && !e.outputs && currentMetadata.execution_count && pendingCellUpdates.has(e.cell)) {
|
||||
// This is a result of the cell being cleared (i.e. we perfomed an update request and this is now the update event).
|
||||
metadata.execution_count = null;
|
||||
metadataUpdated = true;
|
||||
pendingCellUpdates.delete(e.cell);
|
||||
}
|
||||
|
||||
if (e.document?.languageId && e.document?.languageId !== preferredCellLanguage && e.document?.languageId !== languageIdInMetadata) {
|
||||
|
|
Loading…
Reference in New Issue