Sfoglia il codice sorgente

Handle executionCount in widget

Steven Silvester 9 anni fa
parent
commit
4158bfc3d5
1 ha cambiato i file con 7 aggiunte e 1 eliminazioni
  1. 7 1
      src/notebook/cells/widget.ts

+ 7 - 1
src/notebook/cells/widget.ts

@@ -303,6 +303,8 @@ class CodeCellWidget extends BaseCellWidget {
     (this.layout as PanelLayout).addChild(this._output);
     this._collapsedCursor = model.getMetadata('collapsed');
     this._scrolledCursor = model.getMetadata('scrolled');
+    let value = model.executionCount;
+    this.setPrompt(`In [${value || ' '}]:`);
   }
 
   /**
@@ -334,12 +336,16 @@ class CodeCellWidget extends BaseCellWidget {
   /**
    * Handle changes in the model.
    */
-  protected onModelChanged(model: ICellModel, change: string): void {
+  protected onModelChanged(model: ICodeCellModel, change: string): void {
     switch (change) {
     case 'metadata.collapsed':
     case 'metadata.scrolled':
       this.update();
       break;
+    case 'executionCount':
+      let value = model.executionCount;
+      this.setPrompt(`In [${value || ' '}]:`);
+      break;
     default:
       break;
     }