From 453caa92d42242f0747b04aa95236171e610d63a Mon Sep 17 00:00:00 2001 From: Chris LaFreniere <40371649+chlafreniere@users.noreply.github.com> Date: Wed, 19 Jun 2019 15:02:03 -0700 Subject: [PATCH] Fix for standard in hovering in code cell (#6107) --- .../parts/notebook/cellViews/code.component.ts | 2 +- .../parts/notebook/cellViews/codeCell.component.ts | 4 +++- src/sql/workbench/parts/notebook/models/cell.ts | 10 ++++++++++ .../workbench/parts/notebook/models/modelInterfaces.ts | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/sql/workbench/parts/notebook/cellViews/code.component.ts b/src/sql/workbench/parts/notebook/cellViews/code.component.ts index f7743f29c7..7c94c8a816 100644 --- a/src/sql/workbench/parts/notebook/cellViews/code.component.ts +++ b/src/sql/workbench/parts/notebook/cellViews/code.component.ts @@ -232,7 +232,7 @@ export class CodeComponent extends AngularDisposable implements OnInit, OnChange })); this._register(this.model.layoutChanged(() => this._layoutEmitter.fire(), this)); this._register(this.cellModel.onExecutionStateChange(event => { - if (event === CellExecutionState.Running) { + if (event === CellExecutionState.Running && !this.cellModel.stdInVisible) { this.setFocusAndScroll(); } })); diff --git a/src/sql/workbench/parts/notebook/cellViews/codeCell.component.ts b/src/sql/workbench/parts/notebook/cellViews/codeCell.component.ts index 01fa7733df..973177836a 100644 --- a/src/sql/workbench/parts/notebook/cellViews/codeCell.component.ts +++ b/src/sql/workbench/parts/notebook/cellViews/codeCell.component.ts @@ -81,6 +81,7 @@ export class CodeCellComponent extends CellView implements OnInit, OnChanges { if (msg) { this.stdIn = msg; this.inputDeferred = new Deferred(); + this.cellModel.stdInVisible = true; this._changeRef.detectChanges(); return this.awaitStdIn(); } @@ -97,11 +98,12 @@ export class CodeCellComponent extends CellView implements OnInit, OnChanges { // Clean up so no matter what, the stdIn request goes away this.stdIn = undefined; this.inputDeferred = undefined; + this.cellModel.stdInVisible = false; this._changeRef.detectChanges(); } } get isStdInVisible(): boolean { - return !!(this.stdIn && this.inputDeferred); + return this.cellModel.stdInVisible; } } diff --git a/src/sql/workbench/parts/notebook/models/cell.ts b/src/sql/workbench/parts/notebook/models/cell.ts index aeb196d20e..e56782abf0 100644 --- a/src/sql/workbench/parts/notebook/models/cell.ts +++ b/src/sql/workbench/parts/notebook/models/cell.ts @@ -42,6 +42,7 @@ export class CellModel implements ICellModel { private _stdInHandler: nb.MessageHandler; private _onCellLoaded = new Emitter(); private _loaded: boolean; + private _stdInVisible: boolean; constructor(cellData: nb.ICellContents, private _options: ICellModelOptions, @@ -56,6 +57,7 @@ export class CellModel implements ICellModel { this._source = ''; } this._isEditMode = this._cellType !== CellTypes.Markdown; + this._stdInVisible = false; if (_options && _options.isTrusted) { this._isTrusted = true; } else { @@ -200,6 +202,14 @@ export class CellModel implements ICellModel { } } + public get stdInVisible(): boolean { + return this._stdInVisible; + } + + public set stdInVisible(val: boolean) { + this._stdInVisible = val; + } + private notifyExecutionComplete(): void { if (this._notebookService) { this._notebookService.serializeNotebookStateChange(this.notebookModel.notebookUri, NotebookChangeType.CellExecuted); diff --git a/src/sql/workbench/parts/notebook/models/modelInterfaces.ts b/src/sql/workbench/parts/notebook/models/modelInterfaces.ts index a2ed97a0d8..8d26cc724e 100644 --- a/src/sql/workbench/parts/notebook/models/modelInterfaces.ts +++ b/src/sql/workbench/parts/notebook/models/modelInterfaces.ts @@ -467,6 +467,7 @@ export interface ICellModel { equals(cellModel: ICellModel): boolean; toJSON(): nb.ICellContents; loaded: boolean; + stdInVisible: boolean; readonly onLoaded: Event; }