Skip to content

Commit ad80711

Browse files
authored
fix cell execution count on rerun (microsoft#250327)
1 parent c718903 commit ad80711

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/vs/workbench/contrib/notebook/browser/view/cellParts/cellExecution.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { NotebookCellInternalMetadata } from '../../../common/notebookCommon.js'
1515
import { INotebookExecutionStateService } from '../../../common/notebookExecutionStateService.js';
1616
import { executingStateIcon } from '../../notebookIcons.js';
1717
import { renderLabelWithIcons } from '../../../../../../base/browser/ui/iconLabel/iconLabels.js';
18+
import { CellViewModelStateChangeEvent } from '../../notebookViewEvents.js';
1819

1920
const UPDATE_EXECUTION_ORDER_GRACE_PERIOD = 200;
2021

@@ -67,6 +68,12 @@ export class CellExecutionPart extends CellContentPart {
6768
this.updateExecutionOrder(element.internalMetadata, true);
6869
}
6970

71+
override updateState(element: ICellViewModel, e: CellViewModelStateChangeEvent): void {
72+
if (e.internalMetadataChanged) {
73+
this.updateExecutionOrder(element.internalMetadata);
74+
}
75+
}
76+
7077
private updateExecutionOrder(internalMetadata: NotebookCellInternalMetadata, forceClear = false): void {
7178
if (this._notebookEditor.activeKernel?.implementsExecutionOrder || (!this._notebookEditor.activeKernel && typeof internalMetadata.executionOrder === 'number')) {
7279
// If the executionOrder was just cleared, and the cell is executing, wait just a bit before clearing the view to avoid flashing
@@ -139,19 +146,19 @@ export class CellExecutionPart extends CellContentPart {
139146
const statusBarVisible = this.currentCell.layoutInfo.statusBarHeight > 0;
140147

141148
// Sticky mode: cell is running and editor is not fully visible
149+
const offset = editorBottom - scrollBottom;
150+
top -= offset;
151+
top = clamp(
152+
top,
153+
lineHeight + 12, // line height + padding for single line
154+
this.currentCell.layoutInfo.editorHeight - lineHeight + this.currentCell.layoutInfo.statusBarHeight
155+
);
156+
142157
if (scrollBottom <= editorBottom && cellIsRunning) {
143-
const offset = editorBottom - scrollBottom;
144-
top -= offset;
145-
top = clamp(
146-
top,
147-
lineHeight + 12, // line height + padding for single line
148-
this.currentCell.layoutInfo.editorHeight - lineHeight + this.currentCell.layoutInfo.statusBarHeight
149-
);
150-
151-
const isAlreadySticky = this._executionOrderLabel.classList.contains('sticky');
158+
const isAlreadyIcon = this._executionOrderContent.classList.contains('sticky-spinner');
152159
// Add a class when it's in sticky mode for special styling
153-
if (!isAlreadySticky) {
154-
this._executionOrderLabel.classList.add('sticky');
160+
if (!isAlreadyIcon) {
161+
this._executionOrderLabel.classList.add('sticky-spinner');
155162
// Only recreate the content if we're newly becoming sticky
156163
DOM.clearNode(this._executionOrderContent);
157164
const icon = ThemeIcon.modify(executingStateIcon, 'spin');

0 commit comments

Comments
 (0)