mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-28 01:25:39 -05:00
Merge from vscode e3c4990c67c40213af168300d1cfeb71d680f877 (#16569)
This commit is contained in:
@@ -318,6 +318,7 @@ export class NotebookFindDecorations implements IDisposable {
|
||||
}
|
||||
|
||||
private static readonly _CURRENT_FIND_MATCH_DECORATION = ModelDecorationOptions.register({
|
||||
description: 'CURRENT_FIND_MATCH_DECORATION',
|
||||
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
|
||||
zIndex: 13,
|
||||
className: 'currentFindMatch',
|
||||
@@ -333,6 +334,7 @@ export class NotebookFindDecorations implements IDisposable {
|
||||
});
|
||||
|
||||
private static readonly _FIND_MATCH_DECORATION = ModelDecorationOptions.register({
|
||||
description: 'FIND_MATCH_DECORATION',
|
||||
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
|
||||
className: 'findMatch',
|
||||
showIfCollapsed: true,
|
||||
@@ -347,12 +349,14 @@ export class NotebookFindDecorations implements IDisposable {
|
||||
});
|
||||
|
||||
private static readonly _FIND_MATCH_NO_OVERVIEW_DECORATION = ModelDecorationOptions.register({
|
||||
description: 'FIND_MATCH_NO_OVERVIEW_DECORATION',
|
||||
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
|
||||
className: 'findMatch',
|
||||
showIfCollapsed: true
|
||||
});
|
||||
|
||||
private static readonly _FIND_MATCH_ONLY_OVERVIEW_DECORATION = ModelDecorationOptions.register({
|
||||
description: 'FIND_MATCH_ONLY_OVERVIEW_DECORATION',
|
||||
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
|
||||
overviewRuler: {
|
||||
color: themeColorFromId(overviewRulerFindMatchForeground),
|
||||
@@ -361,12 +365,14 @@ export class NotebookFindDecorations implements IDisposable {
|
||||
});
|
||||
|
||||
private static readonly _RANGE_HIGHLIGHT_DECORATION = ModelDecorationOptions.register({
|
||||
description: 'RANGE_HIGHLIGHT_DECORATION',
|
||||
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
|
||||
className: 'rangeHighlight',
|
||||
isWholeLine: false
|
||||
});
|
||||
|
||||
private static readonly _FIND_SCOPE_DECORATION = ModelDecorationOptions.register({
|
||||
description: 'FIND_SCOPE_DECORATION',
|
||||
className: 'findScope',
|
||||
isWholeLine: true
|
||||
});
|
||||
|
||||
@@ -130,9 +130,9 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
|
||||
if (FIND_WIDGET_INITIAL_WIDTH + 28 + minimapWidth - MAX_MATCHES_COUNT_WIDTH >= editorWidth + 50) {
|
||||
collapsedFindWidget = true;
|
||||
}
|
||||
dom.toggleClass(this._domNode, 'collapsed-find-widget', collapsedFindWidget);
|
||||
dom.toggleClass(this._domNode, 'narrow-find-widget', narrowFindWidget);
|
||||
dom.toggleClass(this._domNode, 'reduced-find-widget', reducedFindWidget);
|
||||
this._domNode.classList.toggle('collapsed-find-widget', collapsedFindWidget);
|
||||
this._domNode.classList.toggle('narrow-find-widget', narrowFindWidget);
|
||||
this._domNode.classList.toggle('reduced-find-widget', reducedFindWidget);
|
||||
|
||||
if (!narrowFindWidget && !collapsedFindWidget) {
|
||||
// the minimal left offset of findwidget is 15px.
|
||||
@@ -215,7 +215,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
|
||||
}
|
||||
if (e.searchString || e.matchesCount || e.matchesPosition) {
|
||||
let showRedOutline = (this._state.searchString.length > 0 && this._state.matchesCount === 0);
|
||||
dom.toggleClass(this._domNode, 'no-results', showRedOutline);
|
||||
this._domNode.classList.toggle('no-results', showRedOutline);
|
||||
|
||||
this._updateMatchesCount();
|
||||
}
|
||||
@@ -568,7 +568,7 @@ class SimpleButton extends Widget {
|
||||
}
|
||||
|
||||
public setEnabled(enabled: boolean): void {
|
||||
dom.toggleClass(this._domNode, 'disabled', !enabled);
|
||||
this._domNode.classList.toggle('disabled', !enabled);
|
||||
this._domNode.setAttribute('aria-disabled', String(!enabled));
|
||||
this._domNode.tabIndex = enabled ? 0 : -1;
|
||||
}
|
||||
@@ -578,6 +578,6 @@ class SimpleButton extends Widget {
|
||||
}
|
||||
|
||||
public toggleClass(className: string, shouldHaveIt: boolean): void {
|
||||
dom.toggleClass(this._domNode, className, shouldHaveIt);
|
||||
this._domNode.classList.toggle(className, shouldHaveIt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
import { SideBySideEditorInput } from 'vs/workbench/common/editor';
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/browser/editors/fileEditorInput';
|
||||
import { SideBySideEditorInput } from 'vs/workbench/common/editor/sideBySideEditorInput';
|
||||
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { FileNotebookInput } from 'sql/workbench/contrib/notebook/browser/models/fileNotebookInput';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/browser/editors/fileEditorInput';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { EditorInput, EditorModel, IRevertOptions, GroupIdentifier, IEditorInput } from 'vs/workbench/common/editor';
|
||||
import { IRevertOptions, GroupIdentifier, IEditorInput, EditorInputCapabilities } from 'vs/workbench/common/editor';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as resources from 'vs/base/common/resources';
|
||||
@@ -12,7 +12,7 @@ import * as azdata from 'azdata';
|
||||
import { IStandardKernelWithProvider, getProvidersForFileName, getStandardKernelsForProvider } from 'sql/workbench/services/notebook/browser/models/notebookUtils';
|
||||
import { INotebookService, DEFAULT_NOTEBOOK_PROVIDER, IProviderInfo } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { ITextEditorModel, ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { INotebookModel, IContentManager, NotebookContentChange } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
|
||||
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
@@ -25,16 +25,18 @@ import { NotebookChangeType } from 'sql/workbench/services/notebook/common/contr
|
||||
import { Deferred } from 'sql/base/common/promise';
|
||||
import { NotebookTextFileModel } from 'sql/workbench/contrib/notebook/browser/models/notebookTextFileModel';
|
||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfigurationService';
|
||||
import { ResourceEditorModel } from 'vs/workbench/common/editor/resourceEditorModel';
|
||||
import { TextResourceEditorModel } from 'vs/workbench/common/editor/textResourceEditorModel';
|
||||
import { UntitledTextEditorModel, IUntitledTextEditorModel } from 'vs/workbench/services/untitled/common/untitledTextEditorModel';
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
|
||||
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
import { AbstractResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/browser/editors/fileEditorInput';
|
||||
import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel';
|
||||
import { NotebookFindModel } from 'sql/workbench/contrib/notebook/browser/find/notebookFindModel';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { NotebookModel } from 'sql/workbench/services/notebook/browser/models/notebookModel';
|
||||
import { INotebookInput } from 'sql/workbench/services/notebook/browser/interface';
|
||||
import { EditorModel } from 'vs/workbench/common/editor/editorModel';
|
||||
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
|
||||
|
||||
export type ModeViewSaveHandler = (handle: number) => Thenable<boolean>;
|
||||
|
||||
@@ -46,7 +48,7 @@ export class NotebookEditorModel extends EditorModel {
|
||||
private _lastEditFullReplacement: boolean;
|
||||
private _isFirstKernelChange: boolean = true;
|
||||
constructor(public readonly notebookUri: URI,
|
||||
private textEditorModel: ITextFileEditorModel | IUntitledTextEditorModel | ResourceEditorModel,
|
||||
private textEditorModel: ITextFileEditorModel | IUntitledTextEditorModel | TextResourceEditorModel,
|
||||
@INotebookService private notebookService: INotebookService,
|
||||
@ITextResourcePropertiesService private textResourcePropertiesService: ITextResourcePropertiesService
|
||||
) {
|
||||
@@ -72,18 +74,18 @@ export class NotebookEditorModel extends EditorModel {
|
||||
}));
|
||||
if (this.textEditorModel instanceof UntitledTextEditorModel) {
|
||||
this._register(this.textEditorModel.onDidChangeDirty(e => {
|
||||
let dirty = this.textEditorModel instanceof ResourceEditorModel ? false : this.textEditorModel.isDirty();
|
||||
let dirty = this.textEditorModel instanceof TextResourceEditorModel ? false : this.textEditorModel.isDirty();
|
||||
this.setDirty(dirty);
|
||||
}));
|
||||
} else {
|
||||
if (this.textEditorModel instanceof TextFileEditorModel) {
|
||||
this._register(this.textEditorModel.onDidSave(() => {
|
||||
let dirty = this.textEditorModel instanceof ResourceEditorModel ? false : this.textEditorModel.isDirty();
|
||||
let dirty = this.textEditorModel instanceof TextResourceEditorModel ? false : this.textEditorModel.isDirty();
|
||||
this.setDirty(dirty);
|
||||
this.sendNotebookSerializationStateChange();
|
||||
}));
|
||||
this._register(this.textEditorModel.onDidChangeDirty(() => {
|
||||
let dirty = this.textEditorModel instanceof ResourceEditorModel ? false : this.textEditorModel.isDirty();
|
||||
let dirty = this.textEditorModel instanceof TextResourceEditorModel ? false : this.textEditorModel.isDirty();
|
||||
this.setDirty(dirty);
|
||||
}));
|
||||
this._register(this.textEditorModel.onDidResolve(async (e) => {
|
||||
@@ -94,7 +96,7 @@ export class NotebookEditorModel extends EditorModel {
|
||||
}));
|
||||
}
|
||||
}
|
||||
this._dirty = this.textEditorModel instanceof ResourceEditorModel ? false : this.textEditorModel.isDirty();
|
||||
this._dirty = this.textEditorModel instanceof TextResourceEditorModel ? false : this.textEditorModel.isDirty();
|
||||
}
|
||||
|
||||
public get contentString(): string {
|
||||
@@ -107,7 +109,7 @@ export class NotebookEditorModel extends EditorModel {
|
||||
}
|
||||
|
||||
isDirty(): boolean {
|
||||
return this.textEditorModel instanceof ResourceEditorModel ? false : this.textEditorModel.isDirty();
|
||||
return this.textEditorModel instanceof TextResourceEditorModel ? false : this.textEditorModel.isDirty();
|
||||
}
|
||||
|
||||
public setDirty(dirty: boolean): void {
|
||||
@@ -208,7 +210,7 @@ export class NotebookEditorModel extends EditorModel {
|
||||
}
|
||||
}
|
||||
|
||||
type TextInput = ResourceEditorInput | UntitledTextEditorInput | FileEditorInput;
|
||||
type TextInput = AbstractResourceEditorInput | UntitledTextEditorInput | FileEditorInput;
|
||||
|
||||
export abstract class NotebookInput extends EditorInput implements INotebookInput {
|
||||
private _providerId: string;
|
||||
@@ -286,8 +288,8 @@ export abstract class NotebookInput extends EditorInput implements INotebookInpu
|
||||
return this._title;
|
||||
}
|
||||
|
||||
public override isReadonly(): boolean {
|
||||
return false;
|
||||
public override get capabilities(): EditorInputCapabilities {
|
||||
return EditorInputCapabilities.None;
|
||||
}
|
||||
|
||||
public async getProviderInfo(): Promise<IProviderInfo> {
|
||||
@@ -384,7 +386,7 @@ export abstract class NotebookInput extends EditorInput implements INotebookInpu
|
||||
if (this._model) {
|
||||
return Promise.resolve(this._model);
|
||||
} else {
|
||||
let textOrUntitledEditorModel: ITextFileEditorModel | IUntitledTextEditorModel | ResourceEditorModel;
|
||||
let textOrUntitledEditorModel: ITextFileEditorModel | IUntitledTextEditorModel | TextResourceEditorModel;
|
||||
if (this.resource.scheme === Schemas.untitled) {
|
||||
if (this._untitledEditorModel) {
|
||||
this._untitledEditorModel.textEditorModel.onBeforeAttached();
|
||||
@@ -392,15 +394,15 @@ export abstract class NotebookInput extends EditorInput implements INotebookInpu
|
||||
} else {
|
||||
let resolvedInput = await this._textInput.resolve();
|
||||
if (!(resolvedInput instanceof BinaryEditorModel)) {
|
||||
resolvedInput.textEditorModel.onBeforeAttached();
|
||||
(resolvedInput as ITextEditorModel).textEditorModel.onBeforeAttached();
|
||||
}
|
||||
textOrUntitledEditorModel = resolvedInput as TextFileEditorModel | UntitledTextEditorModel | ResourceEditorModel;
|
||||
textOrUntitledEditorModel = resolvedInput as TextFileEditorModel | UntitledTextEditorModel | TextResourceEditorModel;
|
||||
}
|
||||
} else {
|
||||
const textEditorModelReference = await this.textModelService.createModelReference(this.resource);
|
||||
textEditorModelReference.object.textEditorModel.onBeforeAttached();
|
||||
await textEditorModelReference.object.resolve();
|
||||
textOrUntitledEditorModel = textEditorModelReference.object as TextFileEditorModel | ResourceEditorModel;
|
||||
textOrUntitledEditorModel = textEditorModelReference.object as TextFileEditorModel | TextResourceEditorModel;
|
||||
}
|
||||
this._model = this._register(this.instantiationService.createInstance(NotebookEditorModel, this.resource, textOrUntitledEditorModel));
|
||||
this.hookDirtyListener(this._model.onDidChangeDirty, () => this._onDidChangeDirty.fire());
|
||||
|
||||
@@ -9,7 +9,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { FILE_EDITOR_INPUT_ID } from 'vs/workbench/contrib/files/common/files';
|
||||
import { FileNotebookInput } from 'sql/workbench/contrib/notebook/browser/models/fileNotebookInput';
|
||||
import { UntitledNotebookInput } from 'sql/workbench/contrib/notebook/browser/models/untitledNotebookInput';
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/browser/editors/fileEditorInput';
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
|
||||
import { ILanguageAssociation } from 'sql/workbench/services/languageAssociation/common/languageAssociation';
|
||||
import { NotebookInput } from 'sql/workbench/contrib/notebook/browser/models/notebookInput';
|
||||
@@ -44,7 +44,7 @@ export class NotebookEditorInputAssociation implements ILanguageAssociation {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
syncConvertinput(activeEditor: IEditorInput): NotebookInput | DiffNotebookInput | undefined {
|
||||
syncConvertInput(activeEditor: IEditorInput): NotebookInput | DiffNotebookInput | undefined {
|
||||
return this.convertInput(activeEditor);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
|
||||
import { NotebookInput } from 'sql/workbench/contrib/notebook/browser/models/notebookInput';
|
||||
import { INotebookService } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
|
||||
import { EditorInputCapabilities } from 'vs/workbench/common/editor';
|
||||
|
||||
export class UntitledNotebookInput extends NotebookInput {
|
||||
public static ID: string = 'workbench.editorinputs.untitledNotebookInput';
|
||||
@@ -34,9 +35,9 @@ export class UntitledNotebookInput extends NotebookInput {
|
||||
this.textInput.setMode(mode);
|
||||
}
|
||||
|
||||
override isUntitled(): boolean {
|
||||
override get capabilities(): EditorInputCapabilities {
|
||||
// Subclasses need to explicitly opt-in to being untitled.
|
||||
return true;
|
||||
return EditorInputCapabilities.Untitled;
|
||||
}
|
||||
|
||||
override get typeId(): string {
|
||||
|
||||
@@ -589,7 +589,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
||||
let secondary: IAction[] = [];
|
||||
let notebookBarMenu = this.menuService.createMenu(MenuId.NotebookToolbar, this.contextKeyService);
|
||||
let groups = notebookBarMenu.getActions({ arg: null, shouldForwardArgs: true });
|
||||
fillInActions(groups, { primary, secondary }, false, '', Number.MAX_SAFE_INTEGER, (action: SubmenuAction, group: string, groupSize: number) => group === undefined || group === '');
|
||||
fillInActions(groups, { primary, secondary }, false, g => g === '', Number.MAX_SAFE_INTEGER, (action: SubmenuAction, group: string, groupSize: number) => group === undefined || group === '');
|
||||
this.addPrimaryContributedActions(primary);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ import { INotebookManager } from 'sql/workbench/services/notebook/browser/notebo
|
||||
import { NotebookExplorerViewletViewsContribution } from 'sql/workbench/contrib/notebook/browser/notebookExplorer/notebookExplorerViewlet';
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ContributedEditorPriority, IEditorOverrideService } from 'vs/workbench/services/editor/common/editorOverrideService';
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/browser/editors/fileEditorInput';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
|
||||
@@ -717,7 +717,7 @@ export class NotebookEditorOverrideContribution extends Disposable implements IW
|
||||
// Create the selector from the list of all the language extensions we want to associate with the
|
||||
// notebook editor (filtering out any languages which didn't have any extensions registered yet)
|
||||
const selector = `*{${langExtensions.join(',')}}`;
|
||||
this._registeredOverrides.add(this._editorOverrideService.registerContributionPoint(
|
||||
this._registeredOverrides.add(this._editorOverrideService.registerEditor(
|
||||
selector,
|
||||
{
|
||||
id: NotebookEditor.ID,
|
||||
@@ -745,7 +745,7 @@ export class NotebookEditorOverrideContribution extends Disposable implements IW
|
||||
|
||||
private tryConvertInput(input: IEditorInput, lang: string): IEditorInput | undefined {
|
||||
const langAssociation = languageAssociationRegistry.getAssociationForLanguage(lang);
|
||||
const notebookEditorInput = langAssociation?.syncConvertinput?.(input);
|
||||
const notebookEditorInput = langAssociation?.syncConvertInput?.(input);
|
||||
if (!notebookEditorInput) {
|
||||
this._logService.warn('Unable to create input for overriding editor ', input instanceof DiffEditorInput ? `${input.primary.resource.toString()} <-> ${input.secondary.resource.toString()}` : input.resource.toString());
|
||||
return undefined;
|
||||
|
||||
@@ -171,7 +171,7 @@ export class NotebookEditorComponent extends AngularDisposable {
|
||||
let secondary: IAction[] = [];
|
||||
let notebookBarMenu = this.menuService.createMenu(MenuId.NotebookToolbar, this.contextKeyService);
|
||||
let groups = notebookBarMenu.getActions({ arg: null, shouldForwardArgs: true });
|
||||
fillInActions(groups, { primary, secondary }, false, '', Number.MAX_SAFE_INTEGER, (action: SubmenuAction, group: string, groupSize: number) => group === undefined || group === '');
|
||||
fillInActions(groups, { primary, secondary }, false, g => g === '', Number.MAX_SAFE_INTEGER, (action: SubmenuAction, group: string, groupSize: number) => group === undefined || group === '');
|
||||
}
|
||||
|
||||
private get modelFactory(): IModelFactory {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { localize } from 'vs/nls';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
|
||||
import { EditorOptions, IEditorOpenContext } from 'vs/workbench/common/editor';
|
||||
import { IEditorOpenContext } from 'vs/workbench/common/editor';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { bootstrapAngular } from 'sql/workbench/services/bootstrap/browser/bootstrapService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -35,6 +35,7 @@ import { NotebookFindDecorations } from 'sql/workbench/contrib/notebook/browser/
|
||||
import { TimeoutTimer } from 'vs/base/common/async';
|
||||
import { BaseTextEditor } from 'vs/workbench/browser/parts/editor/textEditor';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { IEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
|
||||
export class NotebookEditor extends EditorPane implements IFindNotebookController {
|
||||
|
||||
@@ -190,7 +191,7 @@ export class NotebookEditor extends EditorPane implements IFindNotebookControlle
|
||||
}
|
||||
}
|
||||
|
||||
public override async setInput(input: NotebookInput, options: EditorOptions, context: IEditorOpenContext): Promise<void> {
|
||||
public override async setInput(input: NotebookInput, options: IEditorOptions, context: IEditorOpenContext): Promise<void> {
|
||||
if (this.input && this.input.matches(input)) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { localize } from 'vs/nls';
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { IAction } from 'vs/base/common/actions';
|
||||
import { $, toggleClass, Dimension, IFocusTracker, getTotalHeight, prepend } from 'vs/base/browser/dom';
|
||||
import { $, Dimension, IFocusTracker, getTotalHeight, prepend } from 'vs/base/browser/dom';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
@@ -381,7 +381,7 @@ export class NotebookExplorerViewPaneContainer extends ViewPaneContainer {
|
||||
}
|
||||
|
||||
override layout(dimension: Dimension): void {
|
||||
toggleClass(this.root, 'narrow', dimension.width <= 300);
|
||||
this.root.classList.toggle('narrow', dimension.width <= 300);
|
||||
super.layout(new Dimension(dimension.width, dimension.height - getTotalHeight(this.searchWidgetsContainerElement)));
|
||||
}
|
||||
|
||||
|
||||
@@ -86,11 +86,11 @@ export class NotebookSearchView extends SearchView {
|
||||
@IStorageService storageService: IStorageService,
|
||||
@IOpenerService openerService: IOpenerService,
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@ICommandService readonly commandService: ICommandService,
|
||||
@ICommandService commandService: ICommandService,
|
||||
@IAdsTelemetryService private _telemetryService: IAdsTelemetryService,
|
||||
) {
|
||||
|
||||
super(options, fileService, editorService, codeEditorService, progressService, notificationService, dialogService, contextViewService, instantiationService, viewDescriptorService, configurationService, contextService, searchWorkbenchService, contextKeyService, replaceService, textFileService, preferencesService, themeService, searchHistoryService, contextMenuService, menuService, accessibilityService, keybindingService, storageService, openerService, telemetryService);
|
||||
super(options, fileService, editorService, codeEditorService, progressService, notificationService, dialogService, commandService, contextViewService, instantiationService, viewDescriptorService, configurationService, contextService, searchWorkbenchService, contextKeyService, replaceService, textFileService, preferencesService, themeService, searchHistoryService, contextMenuService, menuService, accessibilityService, keybindingService, storageService, openerService, telemetryService);
|
||||
|
||||
this.memento = new Memento(this.id, storageService);
|
||||
this.viewletState = this.memento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
|
||||
@@ -164,7 +164,7 @@ export class NotebookSearchView extends SearchView {
|
||||
}
|
||||
|
||||
const actionsPosition = this.searchConfig.actionsPosition;
|
||||
dom.toggleClass(this.getContainer(), SearchView.ACTIONS_RIGHT_CLASS_NAME, actionsPosition === 'right');
|
||||
this.getContainer().classList.toggle(SearchView.ACTIONS_RIGHT_CLASS_NAME, actionsPosition === 'right');
|
||||
|
||||
const messagesSize = this.messagesElement.style.display === 'none' ?
|
||||
0 :
|
||||
|
||||
@@ -85,7 +85,7 @@ export class NotebookViewsCellModel extends CellModel {
|
||||
*/
|
||||
public override get outputs(): Array<nb.ICellOutput> {
|
||||
return super.outputs
|
||||
.filter((output: nb.IDisplayResult) => output.data === undefined || output?.data['text/plain'] !== '<IPython.core.display.HTML object>')
|
||||
.filter((output: nb.ICellOutput) => (output as nb.IDisplayResult)?.data === undefined || (output as nb.IDisplayResult)?.data['text/plain'] !== '<IPython.core.display.HTML object>')
|
||||
.map((output: nb.ICellOutput) => ({ ...output }))
|
||||
.map((output: nb.ICellOutput) => { output.metadata = { ...output.metadata }; return output; });
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Component, OnInit, ViewChildren, QueryList, Input, Inject, forwardRef,
|
||||
import { NotebookViewsCardComponent } from 'sql/workbench/contrib/notebook/browser/notebookViews/notebookViewsCard.component';
|
||||
import { ICellModel } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
|
||||
import { NotebookModel } from 'sql/workbench/services/notebook/browser/models/notebookModel';
|
||||
import { GridStack, GridStackEvent, GridStackNode } from 'gridstack';
|
||||
import { GridItemHTMLElement, GridStack, GridStackEvent, GridStackNode } from 'gridstack';
|
||||
import { localize } from 'vs/nls';
|
||||
import { NotebookViewsExtension } from 'sql/workbench/services/notebook/browser/notebookViews/notebookViewsExtension';
|
||||
import { CellChangeEvent, INotebookView, INotebookViewCell } from 'sql/workbench/services/notebook/browser/notebookViews/notebookViews';
|
||||
@@ -72,9 +72,13 @@ export class NotebookViewsGridComponent extends AngularDisposable implements OnI
|
||||
this._loaded = true;
|
||||
this.detectChanges();
|
||||
|
||||
self._grid.on('added', function (e: Event, items: GridStackNode[]) { if (self._gridEnabled) { self.persist('added', items, self._grid, self._items); } });
|
||||
self._grid.on('removed', function (e: Event, items: GridStackNode[]) { if (self._gridEnabled) { self.persist('removed', items, self._grid, self._items); } });
|
||||
self._grid.on('change', function (e: Event, items: GridStackNode[]) { if (self._gridEnabled) { self.persist('change', items, self._grid, self._items); } });
|
||||
let getGridStackItems = (items: GridStackNode[] | GridItemHTMLElement): GridStackNode[] => {
|
||||
return Array.isArray(items) ? items : (items?.gridstackNode ? [items.gridstackNode] : []);
|
||||
};
|
||||
|
||||
self._grid.on('added', function (e: Event, items: GridStackNode[] | GridItemHTMLElement) { if (self._gridEnabled) { self.persist('added', getGridStackItems(items), self._grid, self._items); } });
|
||||
self._grid.on('removed', function (e: Event, items: GridStackNode[] | GridItemHTMLElement) { if (self._gridEnabled) { self.persist('removed', getGridStackItems(items), self._grid, self._items); } });
|
||||
self._grid.on('change', function (e: Event, items: GridStackNode[] | GridItemHTMLElement) { if (self._gridEnabled) { self.persist('change', getGridStackItems(items), self._grid, self._items); } });
|
||||
}
|
||||
|
||||
ngAfterContentChecked() {
|
||||
|
||||
@@ -40,7 +40,6 @@ import { IQueryModelService } from 'sql/workbench/services/query/common/queryMod
|
||||
import { ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { QueryResultId } from 'sql/workbench/services/notebook/browser/models/cell';
|
||||
import { equals } from 'vs/base/common/arrays';
|
||||
import { IDisposableDataProvider } from 'sql/base/common/dataProvider';
|
||||
@@ -481,7 +480,7 @@ export class DataResourceDataProvider implements IGridDataProvider {
|
||||
return result;
|
||||
};
|
||||
|
||||
let serializeRequestParams: SerializeDataParams = <SerializeDataParams>assign(serializer.getBasicSaveParameters(format), <Partial<SerializeDataParams>>{
|
||||
let serializeRequestParams: SerializeDataParams = <SerializeDataParams>Object.assign(serializer.getBasicSaveParameters(format), <Partial<SerializeDataParams>>{
|
||||
saveFormat: format,
|
||||
columns: columns,
|
||||
filePath: filePath.fsPath,
|
||||
|
||||
@@ -15,7 +15,7 @@ import { DataResourceDataProvider } from '../../browser/outputs/gridOutput.compo
|
||||
import { IDataResource } from 'sql/workbench/services/notebook/browser/sql/sqlSessionManager';
|
||||
import { ResultSetSummary } from 'sql/workbench/services/query/common/query';
|
||||
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
||||
import { TestFileDialogService, TestEditorService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { TestFileDialogService, TestEditorService, TestPathService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { TestContextService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { SerializationService } from 'sql/platform/serialization/common/serializationService';
|
||||
import { SaveFormat, ResultSerializer } from 'sql/workbench/services/query/common/resultSerializer';
|
||||
@@ -47,7 +47,7 @@ export class TestSerializationProvider implements azdata.SerializationProvider {
|
||||
}
|
||||
|
||||
suite('Data Resource Data Provider', function () {
|
||||
let fileDialogService: TypeMoq.Mock<TestFileDialogService>;
|
||||
let fileDialogService: TestFileDialogService;
|
||||
let serializer: ResultSerializer;
|
||||
let notificationService: TestNotificationService;
|
||||
let serializationService: SerializationService;
|
||||
@@ -75,7 +75,8 @@ suite('Data Resource Data Provider', function () {
|
||||
let editorService = TypeMoq.Mock.ofType(TestEditorService, TypeMoq.MockBehavior.Strict);
|
||||
editorService.setup(x => x.openEditor(TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
|
||||
let contextService = new TestContextService();
|
||||
fileDialogService = TypeMoq.Mock.ofType(TestFileDialogService, TypeMoq.MockBehavior.Strict);
|
||||
let pathService = new TestPathService();
|
||||
fileDialogService = new TestFileDialogService(pathService);
|
||||
notificationService = new TestNotificationService();
|
||||
serializationService = new SerializationService(undefined, undefined); //_connectionService _capabilitiesService
|
||||
serializationService.registerProvider('testProviderId', new TestSerializationProvider());
|
||||
@@ -84,7 +85,7 @@ suite('Data Resource Data Provider', function () {
|
||||
undefined, // IConfigurationService
|
||||
editorService.object,
|
||||
contextService,
|
||||
fileDialogService.object,
|
||||
fileDialogService,
|
||||
notificationService,
|
||||
undefined // IOpenerService
|
||||
);
|
||||
@@ -108,15 +109,15 @@ suite('Data Resource Data Provider', function () {
|
||||
instantiationService.object
|
||||
);
|
||||
let noHeadersFile = URI.file(path.join(tempFolderPath, 'result_noHeaders.csv'));
|
||||
let fileDialogServiceStub = sinon.stub(fileDialogService.object, 'showSaveDialog').returns(Promise.resolve(noHeadersFile));
|
||||
let serializerStub = sinon.stub(serializer, 'getBasicSaveParameters').returns({ resultFormat: SaveFormat.CSV as string, includeHeaders: false });
|
||||
let fileDialogServiceStub = sinon.stub(fileDialogService, 'showSaveDialog').returns(Promise.resolve(noHeadersFile));
|
||||
let serializerStub = sinon.stub(serializer, 'getBasicSaveParameters').returns(<azdata.SaveResultsRequestParams>{ resultFormat: SaveFormat.CSV as string, includeHeaders: false });
|
||||
await dataResourceDataProvider.serializeResults(SaveFormat.CSV, undefined);
|
||||
fileDialogServiceStub.restore();
|
||||
serializerStub.restore();
|
||||
|
||||
let withHeadersFile = URI.file(path.join(tempFolderPath, 'result_withHeaders.csv'));
|
||||
fileDialogServiceStub = sinon.stub(fileDialogService.object, 'showSaveDialog').returns(Promise.resolve(withHeadersFile));
|
||||
serializerStub = sinon.stub(serializer, 'getBasicSaveParameters').returns({ resultFormat: SaveFormat.CSV as string, includeHeaders: true });
|
||||
fileDialogServiceStub = sinon.stub(fileDialogService, 'showSaveDialog').returns(Promise.resolve(withHeadersFile));
|
||||
serializerStub = sinon.stub(serializer, 'getBasicSaveParameters').returns(<azdata.SaveResultsRequestParams>{ resultFormat: SaveFormat.CSV as string, includeHeaders: true });
|
||||
await dataResourceDataProvider.serializeResults(SaveFormat.CSV, undefined);
|
||||
fileDialogServiceStub.restore();
|
||||
serializerStub.restore();
|
||||
|
||||
@@ -73,7 +73,7 @@ suite('MarkdownTextTransformer', () => {
|
||||
undefined,
|
||||
undefined,
|
||||
);
|
||||
mockNotebookService = TypeMoq.Mock.ofInstance(notebookService);
|
||||
mockNotebookService = TypeMoq.Mock.ofInstance<INotebookService>(notebookService);
|
||||
|
||||
cellModel = new CellModel(undefined, undefined, mockNotebookService.object);
|
||||
notebookEditor = new NotebookEditorStub({ cellGuid: cellModel.cellGuid, instantiationService: instantiationService });
|
||||
|
||||
@@ -577,7 +577,7 @@ suite('Notebook Actions', function (): void {
|
||||
let setOptionsSpy: sinon.SinonSpy;
|
||||
|
||||
setup(async () => {
|
||||
sandbox = sinon.sandbox.create();
|
||||
sandbox = sinon.createSandbox();
|
||||
container = document.createElement('div');
|
||||
contextViewProvider = new ContextViewProviderStub();
|
||||
const instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
|
||||
@@ -44,7 +44,6 @@ import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { EditorOptions } from 'vs/workbench/common/editor';
|
||||
import { ICell } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
@@ -58,6 +57,7 @@ import { workbenchInstantiationService } from 'vs/workbench/test/browser/workben
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { IHostColorSchemeService } from 'vs/workbench/services/themes/common/hostColorSchemeService';
|
||||
import { CellModel } from 'sql/workbench/services/notebook/browser/models/cell';
|
||||
import { IEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
|
||||
class NotebookModelStub extends stubs.NotebookModelStub {
|
||||
public contentChangedEmitter = new Emitter<NotebookContentChange>();
|
||||
@@ -132,7 +132,7 @@ suite('Test class NotebookEditor:', () => {
|
||||
const testNotebookEditor = new NotebookEditorStub({ cellGuid: cellTextEditorGuid, editor: queryTextEditor, model: notebookModel, notebookParams: <INotebookParams>{ notebookUri: untitledNotebookInput.notebookUri } });
|
||||
notebookService.addNotebookEditor(testNotebookEditor);
|
||||
notebookEditor.clearInput();
|
||||
await notebookEditor.setInput(untitledNotebookInput, EditorOptions.create({ pinned: true }), undefined);
|
||||
await notebookEditor.setInput(untitledNotebookInput, { pinned: true }, undefined);
|
||||
untitledNotebookInput.notebookFindModel.notebookModel = undefined; // clear preexisting notebookModel
|
||||
const result = await notebookEditor.getNotebookModel();
|
||||
assert.strictEqual(result, notebookModel, `getNotebookModel() should return the model set in the INotebookEditor object`);
|
||||
@@ -215,7 +215,7 @@ suite('Test class NotebookEditor:', () => {
|
||||
|
||||
test('Tests setInput call with various states of input on a notebookEditor object', async () => {
|
||||
createEditor(notebookEditor);
|
||||
const editorOptions = EditorOptions.create({ pinned: true });
|
||||
const editorOptions: IEditorOptions = { pinned: true };
|
||||
for (const input of [
|
||||
untitledNotebookInput /* set to a known input */,
|
||||
untitledNotebookInput /* tries to set the same input that was previously set */
|
||||
@@ -227,7 +227,7 @@ suite('Test class NotebookEditor:', () => {
|
||||
|
||||
test('Tests setInput call with various states of findState.isRevealed on a notebookEditor object', async () => {
|
||||
createEditor(notebookEditor);
|
||||
const editorOptions = EditorOptions.create({ pinned: true });
|
||||
const editorOptions: IEditorOptions = { pinned: true };
|
||||
for (const isRevealed of [true, false]) {
|
||||
notebookEditor['_findState']['_isRevealed'] = isRevealed;
|
||||
notebookEditor.clearInput();
|
||||
@@ -754,7 +754,7 @@ async function setupNotebookEditor(notebookEditor: NotebookEditor, untitledNoteb
|
||||
}
|
||||
|
||||
async function setInputDocument(notebookEditor: NotebookEditor, untitledNotebookInput: UntitledNotebookInput): Promise<void> {
|
||||
const editorOptions = EditorOptions.create({ pinned: true });
|
||||
const editorOptions: IEditorOptions = { pinned: true };
|
||||
await notebookEditor.setInput(untitledNotebookInput, editorOptions, undefined);
|
||||
assert.strictEqual(notebookEditor.options, editorOptions, 'NotebookEditor options must be the ones that we set');
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import { IExtensionService, NullExtensionService } from 'vs/workbench/services/e
|
||||
import { INotebookService, IProviderInfo } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
|
||||
import { EditorInputCapabilities } from 'vs/workbench/common/editor';
|
||||
|
||||
suite('Notebook Input', function (): void {
|
||||
const instantiationService = workbenchInstantiationService();
|
||||
@@ -64,13 +65,13 @@ suite('Notebook Input', function (): void {
|
||||
|
||||
let inputId = fileNotebookInput.typeId;
|
||||
assert.strictEqual(inputId, FileNotebookInput.ID);
|
||||
assert.strictEqual(fileNotebookInput.isUntitled(), false, 'File Input should not be untitled');
|
||||
assert.strictEqual(fileNotebookInput.hasCapability(EditorInputCapabilities.Untitled), false, 'File Input should not be untitled');
|
||||
});
|
||||
|
||||
test('Untitled Notebook Input', async function (): Promise<void> {
|
||||
let inputId = untitledNotebookInput.typeId;
|
||||
assert.strictEqual(inputId, UntitledNotebookInput.ID);
|
||||
assert.ok(untitledNotebookInput.isUntitled(), 'Untitled Input should be untitled');
|
||||
assert.ok(untitledNotebookInput.hasCapability(EditorInputCapabilities.Untitled), 'Untitled Input should be untitled');
|
||||
});
|
||||
|
||||
test('Getters and Setters', async function (): Promise<void> {
|
||||
|
||||
@@ -164,7 +164,7 @@ suite.skip('NotebookService:', function (): void {
|
||||
notebookService = new NotebookService(lifecycleService, storageService, extensionServiceMock.object, extensionManagementService,
|
||||
instantiationService, fileService, logServiceMock.object, queryManagementService, contextService, productService,
|
||||
editorService, untitledTextEditorService, editorGroupsService, configurationService);
|
||||
sandbox = sinon.sandbox.create();
|
||||
sandbox = sinon.createSandbox();
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -412,7 +412,7 @@ suite.skip('NotebookService:', function (): void {
|
||||
id: 'id1'
|
||||
}
|
||||
});
|
||||
const targetMethodSpy = sandbox.spy(notebookService, methodName);
|
||||
const targetMethodSpy = sandbox.spy(notebookService, methodName as keyof NotebookService);
|
||||
didUninstallExtensionEmitter.fire(extensionIdentifier);
|
||||
assert.ok(targetMethodSpy.calledWithExactly(extensionIdentifier.identifier, extensionServiceMock.object), `call arguments to ${methodName} should be ${extensionIdentifier.identifier} & ${extensionServiceMock.object}`);
|
||||
assert.ok(targetMethodSpy.calledOnce, `${methodName} should be called exactly once`);
|
||||
@@ -432,7 +432,7 @@ suite.skip('NotebookService:', function (): void {
|
||||
id: 'id1'
|
||||
}
|
||||
});
|
||||
const targetMethodSpy = sandbox.spy(notebookService, methodName);
|
||||
const targetMethodSpy = sandbox.spy(notebookService, methodName as keyof NotebookService);
|
||||
// the following call will encounter an exception internally with extensionService.getExtensions() returning undefined.
|
||||
didUninstallExtensionEmitter.fire(extensionIdentifier);
|
||||
assert.ok(targetMethodSpy.calledWithExactly(extensionIdentifier.identifier, extensionServiceMock.object), `call arguments to ${methodName} should be ${extensionIdentifier.identifier} & ${extensionServiceMock.object}`);
|
||||
|
||||
@@ -240,8 +240,8 @@ suite('NotebookViewModel', function (): void {
|
||||
function setupServices() {
|
||||
mockSessionManager = TypeMoq.Mock.ofType(SessionManager);
|
||||
notebookManagers[0].sessionManager = mockSessionManager.object;
|
||||
notificationService = TypeMoq.Mock.ofType(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
capabilitiesService = TypeMoq.Mock.ofType(TestCapabilitiesService);
|
||||
notificationService = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
capabilitiesService = TypeMoq.Mock.ofType<ICapabilitiesService>(TestCapabilitiesService);
|
||||
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
|
||||
memento.setup(x => x.getMemento(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => void 0);
|
||||
queryConnectionService = TypeMoq.Mock.ofType(TestConnectionManagementService, TypeMoq.MockBehavior.Loose, memento.object, undefined, new TestStorageService());
|
||||
|
||||
@@ -73,7 +73,7 @@ suite('Notebook Views Actions', function (): void {
|
||||
let sandbox: sinon.SinonSandbox;
|
||||
|
||||
setup(() => {
|
||||
sandbox = sinon.sandbox.create();
|
||||
sandbox = sinon.createSandbox();
|
||||
setupServices();
|
||||
});
|
||||
|
||||
@@ -95,7 +95,7 @@ suite('Notebook Views Actions', function (): void {
|
||||
assert.deepStrictEqual(notebookViews.getActiveView(), newView, 'Active view not set properly');
|
||||
|
||||
const deleteAction = new DeleteViewAction(notebookViews, dialogService, notificationService);
|
||||
sandbox.stub(deleteAction, 'confirmDelete').withArgs(newView).returns(Promise.resolve(true));
|
||||
sandbox.stub(deleteAction, 'confirmDelete' as keyof DeleteViewAction).withArgs(newView).returns(Promise.resolve(true));
|
||||
await deleteAction.run();
|
||||
|
||||
assert.strictEqual(notebookViews.getViews().length, 0, 'View not deleted');
|
||||
@@ -116,7 +116,7 @@ suite('Notebook Views Actions', function (): void {
|
||||
assert.strictEqual(notebookViews.getActiveView(), newView, 'Active view not set properly');
|
||||
|
||||
const deleteAction = new DeleteViewAction(notebookViews, dialogService, notificationService);
|
||||
sandbox.stub(deleteAction, 'confirmDelete').withArgs(newView).returns(Promise.resolve(false));
|
||||
sandbox.stub(deleteAction, 'confirmDelete' as keyof DeleteViewAction).withArgs(newView).returns(Promise.resolve(false));
|
||||
await deleteAction.run();
|
||||
|
||||
assert.strictEqual(notebookViews.getViews().length, 1, 'View should not have deleted');
|
||||
@@ -165,8 +165,8 @@ suite('Notebook Views Actions', function (): void {
|
||||
function setupServices() {
|
||||
mockSessionManager = TypeMoq.Mock.ofType(SessionManager);
|
||||
notebookManagers[0].sessionManager = mockSessionManager.object;
|
||||
notificationService = TypeMoq.Mock.ofType(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
capabilitiesService = TypeMoq.Mock.ofType(TestCapabilitiesService);
|
||||
notificationService = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
capabilitiesService = TypeMoq.Mock.ofType<ICapabilitiesService>(TestCapabilitiesService);
|
||||
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
|
||||
memento.setup(x => x.getMemento(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => void 0);
|
||||
queryConnectionService = TypeMoq.Mock.ofType(TestConnectionManagementService, TypeMoq.MockBehavior.Loose, memento.object, undefined, new TestStorageService());
|
||||
|
||||
@@ -132,8 +132,8 @@ suite('NotebookViews', function (): void {
|
||||
function setupServices() {
|
||||
mockSessionManager = TypeMoq.Mock.ofType(SessionManager);
|
||||
notebookManagers[0].sessionManager = mockSessionManager.object;
|
||||
notificationService = TypeMoq.Mock.ofType(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
capabilitiesService = TypeMoq.Mock.ofType(TestCapabilitiesService);
|
||||
notificationService = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
capabilitiesService = TypeMoq.Mock.ofType<ICapabilitiesService>(TestCapabilitiesService);
|
||||
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
|
||||
memento.setup(x => x.getMemento(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => void 0);
|
||||
queryConnectionService = TypeMoq.Mock.ofType(TestConnectionManagementService, TypeMoq.MockBehavior.Loose, memento.object, undefined, new TestStorageService());
|
||||
|
||||
@@ -19,7 +19,6 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IModelContentChangedEvent } from 'vs/editor/common/model/textModelEvents';
|
||||
@@ -741,15 +740,15 @@ suite('Cell Model', function (): void {
|
||||
let content = JSON.stringify(cell.toJSON(), undefined, ' ');
|
||||
let contentSplit = content.split('\n');
|
||||
assert.equal(contentSplit.length, 9);
|
||||
assert(startsWith(contentSplit[0].trim(), '{'));
|
||||
assert(startsWith(contentSplit[1].trim(), '"cell_type": "code",'));
|
||||
assert(startsWith(contentSplit[2].trim(), '"source": ""'));
|
||||
assert(startsWith(contentSplit[3].trim(), '"metadata": {'));
|
||||
assert(startsWith(contentSplit[4].trim(), '"azdata_cell_guid": "'));
|
||||
assert(startsWith(contentSplit[5].trim(), '}'));
|
||||
assert(startsWith(contentSplit[6].trim(), '"outputs": []'));
|
||||
assert(startsWith(contentSplit[7].trim(), '"execution_count": null'));
|
||||
assert(startsWith(contentSplit[8].trim(), '}'));
|
||||
assert(contentSplit[0].trim().startsWith('{'));
|
||||
assert(contentSplit[1].trim().startsWith('"cell_type": "code",'));
|
||||
assert(contentSplit[2].trim().startsWith('"source": ""'));
|
||||
assert(contentSplit[3].trim().startsWith('"metadata": {'));
|
||||
assert(contentSplit[4].trim().startsWith('"azdata_cell_guid": "'));
|
||||
assert(contentSplit[5].trim().startsWith('}'));
|
||||
assert(contentSplit[6].trim().startsWith('"outputs": []'));
|
||||
assert(contentSplit[7].trim().startsWith('"execution_count": null'));
|
||||
assert(contentSplit[8].trim().startsWith('}'));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ suite('Client Session', function (): void {
|
||||
notebookManager = new NotebookManagerStub();
|
||||
notebookManager.serverManager = serverManager;
|
||||
notebookManager.sessionManager = mockSessionManager.object;
|
||||
notificationService = TypeMoq.Mock.ofType(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
notificationService = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
|
||||
session = new ClientSession({
|
||||
notebookManager: notebookManager,
|
||||
|
||||
@@ -58,11 +58,11 @@ suite('Local Content Manager', function (): void {
|
||||
override async readFile(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileContent> {
|
||||
const content = await promisify(fs.readFile)(resource.fsPath);
|
||||
|
||||
return { name: ',', size: 0, etag: '', mtime: 0, value: VSBuffer.fromString(content.toString()), resource, ctime: 0 };
|
||||
return { name: ',', size: 0, etag: '', mtime: 0, value: VSBuffer.fromString(content.toString()), resource, ctime: 0, readonly: false };
|
||||
}
|
||||
override async writeFile(resource: URI, bufferOrReadable: VSBuffer | VSBufferReadable, options?: IWriteFileOptions): Promise<IFileStatWithMetadata> {
|
||||
await pfs.writeFile(resource.fsPath, bufferOrReadable.toString());
|
||||
return { resource: resource, mtime: 0, etag: '', size: 0, name: '', isDirectory: false, ctime: 0, isFile: true, isSymbolicLink: false };
|
||||
await pfs.Promises.writeFile(resource.fsPath, bufferOrReadable.toString());
|
||||
return { resource: resource, mtime: 0, etag: '', size: 0, name: '', isDirectory: false, ctime: 0, isFile: true, isSymbolicLink: false, readonly: false };
|
||||
}
|
||||
};
|
||||
instantiationService.set(IFileService, fileService);
|
||||
|
||||
@@ -34,8 +34,6 @@ import { nb } from 'azdata';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { INotebookEditor, INotebookManager } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { TestStorageService, TestTextResourcePropertiesService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
@@ -172,7 +170,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
|
||||
teardown(() => {
|
||||
if (accessor && accessor.textFileService && accessor.textFileService.files) {
|
||||
(<TextFileEditorModelManager>accessor.textFileService.files).clear();
|
||||
(<TextFileEditorModelManager>accessor.textFileService.files).dispose();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -663,7 +661,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(10 + i * 21), ' ],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14 + i * 21), ' "outputs": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(25 + i * 21), ' "execution_count": null');
|
||||
assert(startsWith(notebookEditorModel.editorModel.textEditorModel.getLineContent(26 + i * 21), ' }'));
|
||||
assert(notebookEditorModel.editorModel.textEditorModel.getLineContent(26 + i * 21).startsWith(' }'));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -971,7 +969,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
});
|
||||
|
||||
async function createNewNotebookModel() {
|
||||
let options: INotebookModelOptions = assign({}, defaultModelOptions, <Partial<INotebookModelOptions>><unknown>{
|
||||
let options: INotebookModelOptions = Object.assign({}, defaultModelOptions, <Partial<INotebookModelOptions>><unknown>{
|
||||
factory: mockModelFactory.object
|
||||
});
|
||||
notebookModel = new NotebookModel(options, undefined, logService, undefined, new NullAdsTelemetryService(), queryConnectionService.object, configurationService);
|
||||
|
||||
@@ -79,8 +79,8 @@ suite('Notebook Find Model', function (): void {
|
||||
|
||||
setup(async () => {
|
||||
sessionReady = new Deferred<void>();
|
||||
notificationService = TypeMoq.Mock.ofType(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
capabilitiesService = TypeMoq.Mock.ofType(TestCapabilitiesService);
|
||||
notificationService = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
capabilitiesService = TypeMoq.Mock.ofType<ICapabilitiesService>(TestCapabilitiesService);
|
||||
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
|
||||
memento.setup(x => x.getMemento(TypeMoq.It.isAny(), TypeMoq.It.isAny()
|
||||
)).returns(() => void 0);
|
||||
@@ -102,7 +102,7 @@ suite('Notebook Find Model', function (): void {
|
||||
layoutChanged: undefined,
|
||||
capabilitiesService: capabilitiesService.object
|
||||
};
|
||||
mockClientSession = TypeMoq.Mock.ofType(ClientSession, undefined, defaultModelOptions);
|
||||
mockClientSession = TypeMoq.Mock.ofType<IClientSession>(ClientSession, undefined, defaultModelOptions);
|
||||
mockClientSession.setup(c => c.initialize()).returns(() => {
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
||||
@@ -29,7 +29,6 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { TestConnectionManagementService } from 'sql/platform/connection/test/common/testConnectionManagementService';
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { NotebookEditorContentManager } from 'sql/workbench/contrib/notebook/browser/models/notebookInput';
|
||||
import { SessionManager } from 'sql/workbench/contrib/notebook/test/emptySessionClasses';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
@@ -38,7 +37,6 @@ import { uriPrefixes } from 'sql/platform/connection/common/utils';
|
||||
import { NullAdsTelemetryService } from 'sql/platform/telemetry/common/adsTelemetryService';
|
||||
import { TestConfigurationService } from 'sql/platform/connection/test/common/testConfigurationService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
|
||||
let expectedNotebookContent: nb.INotebookContents = {
|
||||
cells: [{
|
||||
@@ -150,7 +148,7 @@ suite('notebook model', function (): void {
|
||||
mockSessionManager = TypeMoq.Mock.ofType(SessionManager);
|
||||
notebookManagers[0].sessionManager = mockSessionManager.object;
|
||||
sessionReady = new Deferred<void>();
|
||||
notificationService = TypeMoq.Mock.ofType(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
notificationService = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
capabilitiesService = new TestCapabilitiesService();
|
||||
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
|
||||
memento.setup(x => x.getMemento(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => void 0);
|
||||
@@ -747,13 +745,13 @@ suite('notebook model', function (): void {
|
||||
assert(!isUndefinedOrNull(model.context), 'context should exist after call to change context');
|
||||
|
||||
let notebookKernelAlias = model.context.serverCapabilities.notebookKernelAlias;
|
||||
let doChangeKernelStub = sinon.spy(model, 'doChangeKernel').withArgs(model.kernelAliases[0]);
|
||||
let doChangeKernelStub = sinon.spy(model, 'doChangeKernel' as keyof NotebookModel);
|
||||
|
||||
model.changeKernel(notebookKernelAlias);
|
||||
assert.equal(model.selectedKernelDisplayName, notebookKernelAlias);
|
||||
assert.equal(model.currentKernelAlias, notebookKernelAlias);
|
||||
sinon.assert.called(doChangeKernelStub);
|
||||
sinon.restore(doChangeKernelStub);
|
||||
sinon.assert.calledWith(doChangeKernelStub, model.kernelAliases[0]);
|
||||
doChangeKernelStub.restore();
|
||||
|
||||
// After closing the notebook
|
||||
await model.handleClosed();
|
||||
@@ -774,14 +772,14 @@ suite('notebook model', function (): void {
|
||||
assert(!isUndefinedOrNull(model.context), 'context should exist after call to change context');
|
||||
|
||||
let notebookKernelAlias = model.context.serverCapabilities.notebookKernelAlias;
|
||||
let doChangeKernelStub = sinon.spy(model, 'doChangeKernel');
|
||||
let doChangeKernelStub = sinon.spy(model, 'doChangeKernel' as keyof NotebookModel);
|
||||
|
||||
// Change kernel first to alias kernel and then connect to SQL connection
|
||||
model.changeKernel(notebookKernelAlias);
|
||||
assert.equal(model.selectedKernelDisplayName, notebookKernelAlias);
|
||||
assert.equal(model.currentKernelAlias, notebookKernelAlias);
|
||||
sinon.assert.called(doChangeKernelStub);
|
||||
sinon.restore(doChangeKernelStub);
|
||||
doChangeKernelStub.restore();
|
||||
|
||||
// Change to SQL connection from Fake connection
|
||||
await changeContextWithConnectionProfile(model);
|
||||
@@ -790,7 +788,7 @@ suite('notebook model', function (): void {
|
||||
assert.equal(model.selectedKernelDisplayName, expectedKernel);
|
||||
assert.equal(model.currentKernelAlias, undefined);
|
||||
sinon.assert.called(doChangeKernelStub);
|
||||
sinon.restore(doChangeKernelStub);
|
||||
doChangeKernelStub.restore();
|
||||
|
||||
// After closing the notebook
|
||||
await model.handleClosed();
|
||||
@@ -815,7 +813,7 @@ suite('notebook model', function (): void {
|
||||
defaultModelOptions.contentManager = mockContentManager.object;
|
||||
|
||||
// And a matching connection profile
|
||||
let expectedConnectionProfile: IConnectionProfile = {
|
||||
let expectedConnectionProfile = <ConnectionProfile>{
|
||||
connectionName: connectionName,
|
||||
serverName: '',
|
||||
databaseName: '',
|
||||
@@ -915,7 +913,7 @@ suite('notebook model', function (): void {
|
||||
sessionReady.resolve();
|
||||
let actualSession: IClientSession = undefined;
|
||||
|
||||
let options: INotebookModelOptions = assign({}, defaultModelOptions, <Partial<INotebookModelOptions>>{
|
||||
let options: INotebookModelOptions = Object.assign({}, defaultModelOptions, <Partial<INotebookModelOptions>>{
|
||||
factory: mockModelFactory.object
|
||||
});
|
||||
let model = new NotebookModel(options, undefined, logService, undefined, new NullAdsTelemetryService(), queryConnectionService.object, configurationService, capabilitiesService);
|
||||
|
||||
Reference in New Issue
Block a user