Revert "Merge from vscode 81d7885dc2e9dc617e1522697a2966bc4025a45d (#5949)" (#5983)

This reverts commit d15a3fcc98.
This commit is contained in:
Karl Burtram
2019-06-11 12:35:58 -07:00
committed by GitHub
parent 95a50b7892
commit 5a7562a37b
926 changed files with 11394 additions and 19540 deletions

View File

@@ -8,7 +8,7 @@ import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/co
import { ICommandHandler, CommandsRegistry } from 'vs/platform/commands/common/commands';
import { SyncActionDescriptor, MenuRegistry, MenuId, ICommandAction } from 'vs/platform/actions/common/actions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
import { IDisposable, combinedDisposable } from 'vs/base/common/lifecycle';
import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
@@ -33,10 +33,10 @@ Registry.add(Extensions.WorkbenchActions, new class implements IWorkbenchActionR
}
private registerWorkbenchCommandFromAction(descriptor: SyncActionDescriptor, alias: string, category?: string, when?: ContextKeyExpr): IDisposable {
const registrations = new DisposableStore();
let registrations: IDisposable[] = [];
// command
registrations.add(CommandsRegistry.registerCommand(descriptor.id, this.createCommandHandler(descriptor)));
registrations.push(CommandsRegistry.registerCommand(descriptor.id, this.createCommandHandler(descriptor)));
// keybinding
const weight = (typeof descriptor.keybindingWeight === 'undefined' ? KeybindingWeight.WorkbenchContrib : descriptor.keybindingWeight);
@@ -72,13 +72,13 @@ Registry.add(Extensions.WorkbenchActions, new class implements IWorkbenchActionR
MenuRegistry.addCommand(command);
registrations.add(MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command, when }));
registrations.push(MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command, when }));
}
// TODO@alex,joh
// support removal of keybinding rule
// support removal of command-ui
return registrations;
return combinedDisposable(registrations);
}
private createCommandHandler(descriptor: SyncActionDescriptor): ICommandHandler {

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Memento, MementoObject } from 'vs/workbench/common/memento';
import { Memento } from 'vs/workbench/common/memento';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { Themable } from 'vs/workbench/common/theme';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
@@ -35,7 +35,7 @@ export class Component extends Themable {
return this.id;
}
protected getMemento(scope: StorageScope): MementoObject {
protected getMemento(scope: StorageScope): object {
return this.memento.getMemento(scope);
}

View File

@@ -20,17 +20,17 @@ export interface IComposite {
/**
* Returns the primary actions of the composite.
*/
getActions(): ReadonlyArray<IAction>;
getActions(): IAction[];
/**
* Returns the secondary actions of the composite.
*/
getSecondaryActions(): ReadonlyArray<IAction>;
getSecondaryActions(): IAction[];
/**
* Returns an array of actions to show in the context menu of the composite
*/
getContextMenuActions(): ReadonlyArray<IAction>;
getContextMenuActions(): IAction[];
/**
* Returns the action item for a specific action.

View File

@@ -23,9 +23,7 @@ import { coalesce } from 'vs/base/common/arrays';
export const ActiveEditorContext = new RawContextKey<string | null>('activeEditor', null);
export const EditorsVisibleContext = new RawContextKey<boolean>('editorIsOpen', false);
export const EditorPinnedContext = new RawContextKey<boolean>('editorPinned', false);
export const EditorGroupActiveEditorDirtyContext = new RawContextKey<boolean>('groupActiveEditorDirty', false);
export const EditorGroupEditorsCountContext = new RawContextKey<number>('groupEditorsCount', 0);
export const NoEditorsVisibleContext: ContextKeyExpr = EditorsVisibleContext.toNegated();
export const TextCompareEditorVisibleContext = new RawContextKey<boolean>('textCompareEditorVisible', false);
export const TextCompareEditorActiveContext = new RawContextKey<boolean>('textCompareEditorActive', false);
@@ -33,7 +31,6 @@ export const ActiveEditorGroupEmptyContext = new RawContextKey<boolean>('activeE
export const MultipleEditorGroupsContext = new RawContextKey<boolean>('multipleEditorGroups', false);
export const SingleEditorGroupsContext = MultipleEditorGroupsContext.toNegated();
export const InEditorZenModeContext = new RawContextKey<boolean>('inZenMode', false);
export const IsCenteredLayoutContext = new RawContextKey<boolean>('isCenteredLayout', false);
export const SplitEditorsVertically = new RawContextKey<boolean>('splitEditorsVertically', false);
/**
@@ -178,7 +175,7 @@ export interface IEditorInputFactoryRegistry {
*
* @param editorInputId the identifier of the editor input
*/
getEditorInputFactory(editorInputId: string): IEditorInputFactory | undefined;
getEditorInputFactory(editorInputId: string): IEditorInputFactory;
/**
* Starts the registry by providing the required services.
@@ -1061,22 +1058,23 @@ export interface IEditorMemento<T> {
class EditorInputFactoryRegistry implements IEditorInputFactoryRegistry {
private instantiationService: IInstantiationService;
private fileInputFactory: IFileInputFactory;
private readonly editorInputFactoryConstructors: Map<string, IConstructorSignature0<IEditorInputFactory>> = new Map();
private readonly editorInputFactoryInstances: Map<string, IEditorInputFactory> = new Map();
private editorInputFactoryConstructors: { [editorInputId: string]: IConstructorSignature0<IEditorInputFactory> } = Object.create(null);
private readonly editorInputFactoryInstances: { [editorInputId: string]: IEditorInputFactory } = Object.create(null);
start(accessor: ServicesAccessor): void {
this.instantiationService = accessor.get(IInstantiationService);
this.editorInputFactoryConstructors.forEach((ctor, key) => {
this.createEditorInputFactory(key, ctor);
});
for (let key in this.editorInputFactoryConstructors) {
const element = this.editorInputFactoryConstructors[key];
this.createEditorInputFactory(key, element);
}
this.editorInputFactoryConstructors.clear();
this.editorInputFactoryConstructors = Object.create(null);
}
private createEditorInputFactory(editorInputId: string, ctor: IConstructorSignature0<IEditorInputFactory>): void {
const instance = this.instantiationService.createInstance(ctor);
this.editorInputFactoryInstances.set(editorInputId, instance);
this.editorInputFactoryInstances[editorInputId] = instance;
}
registerFileInputFactory(factory: IFileInputFactory): void {
@@ -1089,14 +1087,14 @@ class EditorInputFactoryRegistry implements IEditorInputFactoryRegistry {
registerEditorInputFactory(editorInputId: string, ctor: IConstructorSignature0<IEditorInputFactory>): void {
if (!this.instantiationService) {
this.editorInputFactoryConstructors.set(editorInputId, ctor);
this.editorInputFactoryConstructors[editorInputId] = ctor;
} else {
this.createEditorInputFactory(editorInputId, ctor);
}
}
getEditorInputFactory(editorInputId: string): IEditorInputFactory | undefined {
return this.editorInputFactoryInstances.get(editorInputId);
getEditorInputFactory(editorInputId: string): IEditorInputFactory {
return this.editorInputFactoryInstances[editorInputId];
}
}

View File

@@ -90,7 +90,7 @@ export class ResourceEditorInput extends EditorInput implements IModeSupport {
ref.dispose();
this.modelReference = null;
throw new Error(`Unexpected model for ResourceInput: ${this.resource}`);
return Promise.reject(new Error(`Unexpected model for ResourceInput: ${this.resource}`));
}
this.cachedModel = model;

View File

@@ -6,12 +6,10 @@
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { isEmptyObject } from 'vs/base/common/types';
export type MementoObject = { [key: string]: any };
export class Memento {
private static readonly globalMementos = new Map<string, ScopedMemento>();
private static readonly workspaceMementos = new Map<string, ScopedMemento>();
private static globalMementos: { [id: string]: ScopedMemento } = Object.create(null);
private static workspaceMementos: { [id: string]: ScopedMemento } = Object.create(null);
private static readonly COMMON_PREFIX = 'memento/';
@@ -21,24 +19,24 @@ export class Memento {
this.id = Memento.COMMON_PREFIX + id;
}
getMemento(scope: StorageScope): MementoObject {
getMemento(scope: StorageScope): object {
// Scope by Workspace
if (scope === StorageScope.WORKSPACE) {
let workspaceMemento = Memento.workspaceMementos.get(this.id);
let workspaceMemento = Memento.workspaceMementos[this.id];
if (!workspaceMemento) {
workspaceMemento = new ScopedMemento(this.id, scope, this.storageService);
Memento.workspaceMementos.set(this.id, workspaceMemento);
Memento.workspaceMementos[this.id] = workspaceMemento;
}
return workspaceMemento.getMemento();
}
// Scope Global
let globalMemento = Memento.globalMementos.get(this.id);
let globalMemento = Memento.globalMementos[this.id];
if (!globalMemento) {
globalMemento = new ScopedMemento(this.id, scope, this.storageService);
Memento.globalMementos.set(this.id, globalMemento);
Memento.globalMementos[this.id] = globalMemento;
}
return globalMemento.getMemento();
@@ -47,13 +45,13 @@ export class Memento {
saveMemento(): void {
// Workspace
const workspaceMemento = Memento.workspaceMementos.get(this.id);
const workspaceMemento = Memento.workspaceMementos[this.id];
if (workspaceMemento) {
workspaceMemento.save();
}
// Global
const globalMemento = Memento.globalMementos.get(this.id);
const globalMemento = Memento.globalMementos[this.id];
if (globalMemento) {
globalMemento.save();
}
@@ -61,17 +59,17 @@ export class Memento {
}
class ScopedMemento {
private readonly mementoObj: MementoObject;
private readonly mementoObj: object;
constructor(private id: string, private scope: StorageScope, private storageService: IStorageService) {
this.mementoObj = this.load();
}
getMemento(): MementoObject {
getMemento(): object {
return this.mementoObj;
}
private load(): MementoObject {
private load(): object {
const memento = this.storageService.get(this.id, this.scope);
if (memento) {
return JSON.parse(memento);

View File

@@ -3,10 +3,10 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { INotification, INotificationHandle, INotificationActions, INotificationProgress, NoOpNotification, Severity, NotificationMessage, IPromptChoice, IStatusMessageOptions } from 'vs/platform/notification/common/notification';
import { INotification, INotificationHandle, INotificationActions, INotificationProgress, NoOpNotification, Severity, NotificationMessage, IPromptChoice } from 'vs/platform/notification/common/notification';
import { toErrorMessage } from 'vs/base/common/errorMessage';
import { Event, Emitter } from 'vs/base/common/event';
import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { Disposable } from 'vs/base/common/lifecycle';
import { isPromiseCanceledError } from 'vs/base/common/errors';
import { Action } from 'vs/base/common/actions';
import { isErrorWithActions } from 'vs/base/common/errorsWithActions';
@@ -15,25 +15,10 @@ import { localize } from 'vs/nls';
export interface INotificationsModel {
//
// Notifications as Toasts/Center
//
readonly notifications: INotificationViewItem[];
readonly onDidNotificationChange: Event<INotificationChangeEvent>;
addNotification(notification: INotification): INotificationHandle;
//
// Notifications as Status
//
readonly statusMessage: IStatusMessageViewItem | undefined;
readonly onDidStatusMessageChange: Event<IStatusMessageChangeEvent>;
showStatusMessage(message: NotificationMessage, options?: IStatusMessageOptions): IDisposable;
notify(notification: INotification): INotificationHandle;
}
export const enum NotificationChangeType {
@@ -60,29 +45,6 @@ export interface INotificationChangeEvent {
kind: NotificationChangeType;
}
export const enum StatusMessageChangeType {
ADD,
REMOVE
}
export interface IStatusMessageViewItem {
message: string;
options?: IStatusMessageOptions;
}
export interface IStatusMessageChangeEvent {
/**
* The status message item this change is about.
*/
item: IStatusMessageViewItem;
/**
* The kind of status message change.
*/
kind: StatusMessageChangeType;
}
export class NotificationHandle implements INotificationHandle {
private readonly _onDidClose: Emitter<void> = new Emitter();
@@ -128,16 +90,13 @@ export class NotificationsModel extends Disposable implements INotificationsMode
private readonly _onDidNotificationChange: Emitter<INotificationChangeEvent> = this._register(new Emitter<INotificationChangeEvent>());
get onDidNotificationChange(): Event<INotificationChangeEvent> { return this._onDidNotificationChange.event; }
private readonly _onDidStatusMessageChange: Emitter<IStatusMessageChangeEvent> = this._register(new Emitter<IStatusMessageChangeEvent>());
get onDidStatusMessageChange(): Event<IStatusMessageChangeEvent> { return this._onDidStatusMessageChange.event; }
private readonly _notifications: INotificationViewItem[] = [];
get notifications(): INotificationViewItem[] { return this._notifications; }
private _statusMessage: IStatusMessageViewItem | undefined;
get statusMessage(): IStatusMessageViewItem | undefined { return this._statusMessage; }
get notifications(): INotificationViewItem[] {
return this._notifications;
}
addNotification(notification: INotification): INotificationHandle {
notify(notification: INotification): INotificationHandle {
const item = this.createViewItem(notification);
if (!item) {
return NotificationsModel.NO_OP_NOTIFICATION; // return early if this is a no-op
@@ -215,26 +174,6 @@ export class NotificationsModel extends Disposable implements INotificationsMode
return item;
}
showStatusMessage(message: NotificationMessage, options?: IStatusMessageOptions): IDisposable {
const item = StatusMessageViewItem.create(message, options);
if (!item) {
return Disposable.None;
}
// Remember as current status message and fire events
this._statusMessage = item;
this._onDidStatusMessageChange.fire({ kind: StatusMessageChangeType.ADD, item });
return toDisposable(() => {
// Only reset status message if the item is still the one we had remembered
if (this._statusMessage === item) {
this._statusMessage = undefined;
this._onDidStatusMessageChange.fire({ kind: StatusMessageChangeType.REMOVE, item });
}
});
}
}
export interface INotificationViewItem {
@@ -682,26 +621,4 @@ export class ChoiceAction extends Action {
this._onDidRun.dispose();
}
}
class StatusMessageViewItem {
static create(notification: NotificationMessage, options?: IStatusMessageOptions): IStatusMessageViewItem | null {
if (!notification || isPromiseCanceledError(notification)) {
return null; // we need a message to show
}
let message: string | undefined;
if (notification instanceof Error) {
message = toErrorMessage(notification, false);
} else if (typeof notification === 'string') {
message = notification;
}
if (!message) {
return null; // we need a message to show
}
return { message, options };
}
}

View File

@@ -8,6 +8,5 @@ import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
export const ActivePanelContext = new RawContextKey<string>('activePanel', '');
export const PanelFocusContext = new RawContextKey<boolean>('panelFocus', false);
export const PanelPositionContext = new RawContextKey<string>('panelPosition', 'bottom');
export interface IPanel extends IComposite { }

View File

@@ -30,12 +30,6 @@ export const TAB_ACTIVE_BACKGROUND = registerColor('tab.activeBackground', {
hc: editorBackground
}, nls.localize('tabActiveBackground', "Active tab background color. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."));
export const TAB_UNFOCUSED_ACTIVE_BACKGROUND = registerColor('tab.unfocusedActiveBackground', {
dark: TAB_ACTIVE_BACKGROUND,
light: TAB_ACTIVE_BACKGROUND,
hc: TAB_ACTIVE_BACKGROUND
}, nls.localize('tabUnfocusedActiveBackground', "Active tab background color in an unfocused group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."));
export const TAB_INACTIVE_BACKGROUND = registerColor('tab.inactiveBackground', {
dark: '#2D2D2D',
light: '#ECECEC',
@@ -144,6 +138,7 @@ export const TAB_UNFOCUSED_INACTIVE_FOREGROUND = registerColor('tab.unfocusedIna
hc: Color.white
}, nls.localize('tabUnfocusedInactiveForeground', "Inactive tab foreground color in an unfocused group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."));
// < --- Editors --- >
export const EDITOR_PANE_BACKGROUND = registerColor('editorPane.background', {
@@ -575,4 +570,4 @@ export class Themable extends Disposable {
return color ? color.toString() : null;
}
}
}

View File

@@ -11,7 +11,7 @@ import { ITreeViewDataProvider } from 'vs/workbench/common/views';
import { localize } from 'vs/nls';
import { IViewlet } from 'vs/workbench/common/viewlet';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
import { IDisposable } from 'vs/base/common/lifecycle';
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
import { values, keys } from 'vs/base/common/map';
import { Registry } from 'vs/platform/registry/common/platform';
@@ -71,12 +71,12 @@ export class ViewContainer {
protected constructor(readonly id: string, readonly hideIfEmpty: boolean, readonly extensionId?: ExtensionIdentifier) { }
}
class ViewContainersRegistryImpl extends Disposable implements IViewContainersRegistry {
class ViewContainersRegistryImpl implements IViewContainersRegistry {
private readonly _onDidRegister = this._register(new Emitter<ViewContainer>());
private readonly _onDidRegister = new Emitter<ViewContainer>();
readonly onDidRegister: Event<ViewContainer> = this._onDidRegister.event;
private readonly _onDidDeregister = this._register(new Emitter<ViewContainer>());
private readonly _onDidDeregister = new Emitter<ViewContainer>();
readonly onDidDeregister: Event<ViewContainer> = this._onDidDeregister.event;
private viewContainers: Map<string, ViewContainer> = new Map<string, ViewContainer>();
@@ -169,15 +169,15 @@ export interface IViewsRegistry {
getViewContainer(id: string): ViewContainer | null;
}
class ViewsRegistry extends Disposable implements IViewsRegistry {
class ViewsRegistry implements IViewsRegistry {
private readonly _onViewsRegistered: Emitter<{ views: IViewDescriptor[], viewContainer: ViewContainer }> = this._register(new Emitter<{ views: IViewDescriptor[], viewContainer: ViewContainer }>());
private readonly _onViewsRegistered: Emitter<{ views: IViewDescriptor[], viewContainer: ViewContainer }> = new Emitter<{ views: IViewDescriptor[], viewContainer: ViewContainer }>();
readonly onViewsRegistered: Event<{ views: IViewDescriptor[], viewContainer: ViewContainer }> = this._onViewsRegistered.event;
private readonly _onViewsDeregistered: Emitter<{ views: IViewDescriptor[], viewContainer: ViewContainer }> = this._register(new Emitter<{ views: IViewDescriptor[], viewContainer: ViewContainer }>());
private readonly _onViewsDeregistered: Emitter<{ views: IViewDescriptor[], viewContainer: ViewContainer }> = new Emitter<{ views: IViewDescriptor[], viewContainer: ViewContainer }>();
readonly onViewsDeregistered: Event<{ views: IViewDescriptor[], viewContainer: ViewContainer }> = this._onViewsDeregistered.event;
private readonly _onDidChangeContainer: Emitter<{ views: IViewDescriptor[], from: ViewContainer, to: ViewContainer }> = this._register(new Emitter<{ views: IViewDescriptor[], from: ViewContainer, to: ViewContainer }>());
private readonly _onDidChangeContainer: Emitter<{ views: IViewDescriptor[], from: ViewContainer, to: ViewContainer }> = new Emitter<{ views: IViewDescriptor[], from: ViewContainer, to: ViewContainer }>();
readonly onDidChangeContainer: Event<{ views: IViewDescriptor[], from: ViewContainer, to: ViewContainer }> = this._onDidChangeContainer.event;
private _viewContainers: ViewContainer[] = [];