This commit is contained in:
Yurong He
2019-04-24 09:04:15 -07:00
committed by GitHub
parent e822091907
commit 07bc5e2de9
3 changed files with 15 additions and 2 deletions

View File

@@ -9,7 +9,7 @@ import { OnInit, Component, Input, Inject, ElementRef, ViewChild, Output, EventE
import { AngularDisposable } from 'sql/base/node/lifecycle';
import { QueryTextEditor } from 'sql/workbench/electron-browser/modelComponents/queryTextEditor';
import { CellToggleMoreActions } from 'sql/workbench/parts/notebook/cellToggleMoreActions';
import { ICellModel, notebookConstants } from 'sql/workbench/parts/notebook/models/modelInterfaces';
import { ICellModel, notebookConstants, CellExecutionState } from 'sql/workbench/parts/notebook/models/modelInterfaces';
import { Taskbar } from 'sql/base/browser/ui/taskbar/taskbar';
import { RunCellAction, CellContext } from 'sql/workbench/parts/notebook/cellViews/codeActions';
import { NotebookModel } from 'sql/workbench/parts/notebook/models/notebookModel';
@@ -229,6 +229,11 @@ 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) {
this.setFocusAndScroll();
}
}));
this.layout();
}
@@ -249,7 +254,6 @@ export class CodeComponent extends AngularDisposable implements OnInit, OnChange
this._actionBar.setContent([
{ action: runCellAction }
]);
this._cellToggleMoreActions.onInit(this.moreActionsElementRef, this.model, this.cellModel);
}

View File

@@ -187,6 +187,14 @@ export class CellModel implements ICellModel {
public async runCell(notificationService?: INotificationService, connectionManagementService?: IConnectionManagementService): Promise<boolean> {
try {
if (!this.active && this !== this.notebookModel.activeCell) {
if (this.notebookModel.activeCell) {
this.notebookModel.activeCell.active = false;
}
this.active = true;
this.notebookModel.activeCell = this;
}
if (connectionManagementService) {
this._connectionManagementService = connectionManagementService;
}

View File

@@ -480,6 +480,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
await this.modelReady;
let uriString = cell.cellUri.toString();
if (this._model.cells.findIndex(c => c.cellUri.toString() === uriString) > -1) {
this.selectCell(cell);
return cell.runCell(this.notificationService, this.connectionManagementService);
} else {
return Promise.reject(new Error(localize('cellNotFound', 'cell with URI {0} was not found in this model', uriString)));