mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 18:48:33 -05:00
Merge from master
This commit is contained in:
@@ -3,34 +3,31 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { Disposable, IDisposable, combinedDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { CommandsRegistry, ICommandService, ICommandHandler } from 'vs/platform/commands/common/commands';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { ContextKeyExpr, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IModelChangedEvent } from 'vs/editor/common/editorCommon';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { StandaloneKeybindingService, applyConfigurationValues } from 'vs/editor/standalone/browser/simpleServices';
|
||||
import { ContextViewService } from 'vs/platform/contextview/browser/contextViewService';
|
||||
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
|
||||
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
|
||||
import { ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import { InternalEditorAction } from 'vs/editor/common/editorAction';
|
||||
import { MenuId, MenuRegistry, IMenuItem } from 'vs/platform/actions/common/actions';
|
||||
import { IDiffEditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import * as aria from 'vs/base/browser/ui/aria/aria';
|
||||
import * as nls from 'vs/nls';
|
||||
import * as browser from 'vs/base/browser/browser';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import * as aria from 'vs/base/browser/ui/aria/aria';
|
||||
import { Disposable, IDisposable, combinedDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
|
||||
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
|
||||
import { IDiffEditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { InternalEditorAction } from 'vs/editor/common/editorAction';
|
||||
import { IModelChangedEvent } from 'vs/editor/common/editorCommon';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { StandaloneKeybindingService, applyConfigurationValues } from 'vs/editor/standalone/browser/simpleServices';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import { IMenuItem, MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
|
||||
import { CommandsRegistry, ICommandHandler, ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ContextKeyExpr, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { ContextViewService } from 'vs/platform/contextview/browser/contextViewService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
|
||||
/**
|
||||
* Description of an action contribution
|
||||
@@ -72,9 +69,9 @@ export interface IActionDescriptor {
|
||||
contextMenuOrder?: number;
|
||||
/**
|
||||
* Method that will be executed when the action is triggered.
|
||||
* @param editor The editor instance is passed in as a convinience
|
||||
* @param editor The editor instance is passed in as a convenience
|
||||
*/
|
||||
run(editor: ICodeEditor): void | TPromise<void>;
|
||||
run(editor: ICodeEditor): void | Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +81,7 @@ export interface IEditorConstructionOptions extends IEditorOptions {
|
||||
/**
|
||||
* The initial model associated with this code editor.
|
||||
*/
|
||||
model?: ITextModel;
|
||||
model?: ITextModel | null;
|
||||
/**
|
||||
* The initial value of the auto created model in the editor.
|
||||
* To not create automatically a model, use `model: null`.
|
||||
@@ -125,13 +122,13 @@ export interface IDiffEditorConstructionOptions extends IDiffEditorOptions {
|
||||
}
|
||||
|
||||
export interface IStandaloneCodeEditor extends ICodeEditor {
|
||||
addCommand(keybinding: number, handler: ICommandHandler, context: string): string;
|
||||
addCommand(keybinding: number, handler: ICommandHandler, context: string): string | null;
|
||||
createContextKey<T>(key: string, defaultValue: T): IContextKey<T>;
|
||||
addAction(descriptor: IActionDescriptor): IDisposable;
|
||||
}
|
||||
|
||||
export interface IStandaloneDiffEditor extends IDiffEditor {
|
||||
addCommand(keybinding: number, handler: ICommandHandler, context: string): string;
|
||||
addCommand(keybinding: number, handler: ICommandHandler, context: string): string | null;
|
||||
createContextKey<T>(key: string, defaultValue: T): IContextKey<T>;
|
||||
addAction(descriptor: IActionDescriptor): IDisposable;
|
||||
|
||||
@@ -185,7 +182,7 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
|
||||
createAriaDomNode();
|
||||
}
|
||||
|
||||
public addCommand(keybinding: number, handler: ICommandHandler, context: string): string {
|
||||
public addCommand(keybinding: number, handler: ICommandHandler, context: string): string | null {
|
||||
if (!this._standaloneKeybindingService) {
|
||||
console.warn('Cannot add command because the editor is configured with an unrecognized KeybindingService');
|
||||
return null;
|
||||
@@ -223,9 +220,8 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
|
||||
);
|
||||
const contextMenuGroupId = _descriptor.contextMenuGroupId || null;
|
||||
const contextMenuOrder = _descriptor.contextMenuOrder || 0;
|
||||
const run = (): TPromise<void> => {
|
||||
const r = _descriptor.run(this);
|
||||
return r ? r : TPromise.as(void 0);
|
||||
const run = (): Promise<void> => {
|
||||
return Promise.resolve(_descriptor.run(this));
|
||||
};
|
||||
|
||||
|
||||
@@ -288,7 +284,7 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
|
||||
|
||||
constructor(
|
||||
domElement: HTMLElement,
|
||||
options: IEditorConstructionOptions,
|
||||
options: IEditorConstructionOptions | undefined,
|
||||
toDispose: IDisposable,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@ICodeEditorService codeEditorService: ICodeEditorService,
|
||||
@@ -305,7 +301,7 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
|
||||
if (typeof options.theme === 'string') {
|
||||
themeService.setTheme(options.theme);
|
||||
}
|
||||
let model: ITextModel = options.model;
|
||||
let _model: ITextModel | null | undefined = options.model;
|
||||
delete options.model;
|
||||
super(domElement, options, instantiationService, codeEditorService, commandService, contextKeyService, keybindingService, themeService, notificationService);
|
||||
|
||||
@@ -313,10 +309,12 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
|
||||
this._configurationService = configurationService;
|
||||
this._register(toDispose);
|
||||
|
||||
if (typeof model === 'undefined') {
|
||||
let model: ITextModel | null;
|
||||
if (typeof _model === 'undefined') {
|
||||
model = (<any>self).monaco.editor.createModel(options.value || '', options.language || 'text/plain');
|
||||
this._ownsModel = true;
|
||||
} else {
|
||||
model = _model;
|
||||
this._ownsModel = false;
|
||||
}
|
||||
|
||||
@@ -339,10 +337,10 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
|
||||
super.updateOptions(newOptions);
|
||||
}
|
||||
|
||||
_attachModel(model: ITextModel): void {
|
||||
_attachModel(model: ITextModel | null): void {
|
||||
super._attachModel(model);
|
||||
if (this._view) {
|
||||
this._contextViewService.setContainer(this._view.domNode.domNode);
|
||||
if (this._modelData) {
|
||||
this._contextViewService.setContainer(this._modelData.view.domNode.domNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,7 +409,7 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon
|
||||
return <StandaloneCodeEditor>super.getModifiedEditor();
|
||||
}
|
||||
|
||||
public addCommand(keybinding: number, handler: ICommandHandler, context: string): string {
|
||||
public addCommand(keybinding: number, handler: ICommandHandler, context: string): string | null {
|
||||
return this.getModifiedEditor().addCommand(keybinding, handler, context);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user