mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Revert "Merge branch 'master' of https://github.com/microsoft/azuredatastudio" (#9844)
This reverts commitec46783e47, reversing changes made to6e6649d006.
This commit is contained in:
@@ -193,12 +193,7 @@ configurationRegistry.registerConfiguration({
|
|||||||
'type': 'boolean',
|
'type': 'boolean',
|
||||||
'default': true,
|
'default': true,
|
||||||
'description': localize('notebook.sqlStopOnError', "SQL kernel: stop Notebook execution when error occurs in a cell.")
|
'description': localize('notebook.sqlStopOnError', "SQL kernel: stop Notebook execution when error occurs in a cell.")
|
||||||
},
|
}
|
||||||
'notebook.allowCommandExecution': {
|
|
||||||
'type': 'boolean',
|
|
||||||
'description': localize('notebook.allowCommandExecution', "Allow notebooks to execute Azure Data Studio Commands using the %%AZDATA_EXECUTE_COMMAND magic."),
|
|
||||||
'default': false
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -25,17 +25,14 @@ import { IModelContentChangedEvent } from 'vs/editor/common/model/textModelEvent
|
|||||||
import { firstIndex, find } from 'vs/base/common/arrays';
|
import { firstIndex, find } from 'vs/base/common/arrays';
|
||||||
import { HideInputTag } from 'sql/platform/notebooks/common/outputRegistry';
|
import { HideInputTag } from 'sql/platform/notebooks/common/outputRegistry';
|
||||||
import { FutureInternal, notebookConstants } from 'sql/workbench/services/notebook/browser/interfaces';
|
import { FutureInternal, notebookConstants } from 'sql/workbench/services/notebook/browser/interfaces';
|
||||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
|
||||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
|
||||||
import { Disposable } from 'vs/base/common/lifecycle';
|
|
||||||
|
|
||||||
let modelId = 0;
|
let modelId = 0;
|
||||||
|
|
||||||
export class CellModel extends Disposable implements ICellModel {
|
export class CellModel implements ICellModel {
|
||||||
public id: string;
|
public id: string;
|
||||||
|
|
||||||
private _cellType: nb.CellType;
|
private _cellType: nb.CellType;
|
||||||
private _source: string[];
|
private _source: string | string[];
|
||||||
private _language: string;
|
private _language: string;
|
||||||
private _cellGuid: string;
|
private _cellGuid: string;
|
||||||
private _future: FutureInternal;
|
private _future: FutureInternal;
|
||||||
@@ -59,22 +56,18 @@ export class CellModel extends Disposable implements ICellModel {
|
|||||||
private _isCollapsed: boolean;
|
private _isCollapsed: boolean;
|
||||||
private _onCollapseStateChanged = new Emitter<boolean>();
|
private _onCollapseStateChanged = new Emitter<boolean>();
|
||||||
private _modelContentChangedEvent: IModelContentChangedEvent;
|
private _modelContentChangedEvent: IModelContentChangedEvent;
|
||||||
private _isCommandExecutionSettingEnabled: boolean;
|
|
||||||
|
|
||||||
constructor(cellData: nb.ICellContents,
|
constructor(cellData: nb.ICellContents,
|
||||||
private _options: ICellModelOptions,
|
private _options: ICellModelOptions,
|
||||||
@optional(INotebookService) private _notebookService?: INotebookService,
|
@optional(INotebookService) private _notebookService?: INotebookService
|
||||||
@optional(ICommandService) private _commandService?: ICommandService,
|
|
||||||
@optional(IConfigurationService) private _configurationService?: IConfigurationService
|
|
||||||
) {
|
) {
|
||||||
super();
|
|
||||||
this.id = `${modelId++}`;
|
this.id = `${modelId++}`;
|
||||||
if (cellData) {
|
if (cellData) {
|
||||||
// Read in contents if available
|
// Read in contents if available
|
||||||
this.fromJSON(cellData);
|
this.fromJSON(cellData);
|
||||||
} else {
|
} else {
|
||||||
this._cellType = CellTypes.Code;
|
this._cellType = CellTypes.Code;
|
||||||
this._source = [''];
|
this._source = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
this._isEditMode = this._cellType !== CellTypes.Markdown;
|
this._isEditMode = this._cellType !== CellTypes.Markdown;
|
||||||
@@ -87,14 +80,6 @@ export class CellModel extends Disposable implements ICellModel {
|
|||||||
// if the fromJson() method was already called and _cellGuid was previously set, don't generate another UUID unnecessarily
|
// if the fromJson() method was already called and _cellGuid was previously set, don't generate another UUID unnecessarily
|
||||||
this._cellGuid = this._cellGuid || generateUuid();
|
this._cellGuid = this._cellGuid || generateUuid();
|
||||||
this.createUri();
|
this.createUri();
|
||||||
if (this._configurationService) {
|
|
||||||
this._isCommandExecutionSettingEnabled = this._configurationService.getValue('notebook.allowCommandExecution');
|
|
||||||
this._register(this._configurationService.onDidChangeConfiguration(e => {
|
|
||||||
if (e.affectsConfiguration('notebook.allowCommandExecution')) {
|
|
||||||
this._isCommandExecutionSettingEnabled = this._configurationService.getValue('notebook.allowCommandExecution');
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public equals(other: ICellModel) {
|
public equals(other: ICellModel) {
|
||||||
@@ -351,7 +336,6 @@ export class CellModel extends Disposable implements ICellModel {
|
|||||||
|
|
||||||
// requestExecute expects a string for the code parameter
|
// requestExecute expects a string for the code parameter
|
||||||
content = Array.isArray(content) ? content.join('') : content;
|
content = Array.isArray(content) ? content.join('') : content;
|
||||||
if (!this.checkForAdsCommandMagic()) {
|
|
||||||
const future = kernel.requestExecute({
|
const future = kernel.requestExecute({
|
||||||
code: content,
|
code: content,
|
||||||
stop_on_error: true
|
stop_on_error: true
|
||||||
@@ -369,7 +353,6 @@ export class CellModel extends Disposable implements ICellModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
let message: string;
|
let message: string;
|
||||||
if (error.message === 'Canceled') {
|
if (error.message === 'Canceled') {
|
||||||
@@ -699,7 +682,7 @@ export class CellModel extends Disposable implements ICellModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private getMultilineSource(source: string | string[]): string[] {
|
private getMultilineSource(source: string | string[]): string | string[] {
|
||||||
if (source === undefined) {
|
if (source === undefined) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -724,29 +707,6 @@ export class CellModel extends Disposable implements ICellModel {
|
|||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run ADS commands via a notebook. Configured by a setting (turned off by default).
|
|
||||||
private checkForAdsCommandMagic(): boolean {
|
|
||||||
if (!this._isCommandExecutionSettingEnabled) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let executeCommandMagic = '%%AZDATA_EXECUTE_COMMAND';
|
|
||||||
if (this._source && this._source.length) {
|
|
||||||
if (this._source[0].startsWith(executeCommandMagic)) {
|
|
||||||
let commandNamePlusArgs = this._source[0].replace(executeCommandMagic + ' ', '');
|
|
||||||
if (commandNamePlusArgs) {
|
|
||||||
let commandName = commandNamePlusArgs.split(' ')[0];
|
|
||||||
if (commandName) {
|
|
||||||
let args = commandNamePlusArgs.replace(commandName + ' ', '');
|
|
||||||
this._commandService.executeCommand(commandName, [args]);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dispose and set current future to undefined
|
// Dispose and set current future to undefined
|
||||||
private disposeFuture() {
|
private disposeFuture() {
|
||||||
if (this._future) {
|
if (this._future) {
|
||||||
|
|||||||
Reference in New Issue
Block a user