Initial VS Code 1.19 source merge (#571)

* Initial 1.19 xcopy

* Fix yarn build

* Fix numerous build breaks

* Next batch of build break fixes

* More build break fixes

* Runtime breaks

* Additional post merge fixes

* Fix windows setup file

* Fix test failures.

* Update license header blocks to refer to source eula
This commit is contained in:
Karl Burtram
2018-01-28 23:37:17 -08:00
committed by GitHub
parent 9a1ac20710
commit 251ae01c3e
8009 changed files with 93378 additions and 35634 deletions

View File

@@ -8,25 +8,24 @@
import 'vs/css!./media/workbench';
import { localize } from 'vs/nls';
import { TPromise, ValueCallback } from 'vs/base/common/winjs.base';
import { TPromise } from 'vs/base/common/winjs.base';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import Event, { Emitter, chain } from 'vs/base/common/event';
import Event, { Emitter } from 'vs/base/common/event';
import DOM = require('vs/base/browser/dom');
import { Builder, $ } from 'vs/base/browser/builder';
import { Delayer, RunOnceScheduler } from 'vs/base/common/async';
import * as browser from 'vs/base/browser/browser';
import { StopWatch } from 'vs/base/common/stopwatch';
import { startTimer } from 'vs/base/node/startupTimers';
import { time } from 'vs/base/common/performance';
import errors = require('vs/base/common/errors');
import { BackupFileService } from 'vs/workbench/services/backup/node/backupFileService';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { toErrorMessage } from 'vs/base/common/errorMessage';
import { Registry } from 'vs/platform/registry/common/platform';
import { isWindows, isLinux, isMacintosh } from 'vs/base/common/platform';
import { Position as EditorPosition, IResourceDiffInput, IUntitledResourceInput, IEditor, IResourceInput } from 'vs/platform/editor/common/editor';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { IEditorInputFactoryRegistry, Extensions as EditorExtensions } from 'vs/workbench/common/editor';
import { HistoryService } from 'vs/workbench/services/history/browser/history';
import { HistoryService } from 'vs/workbench/services/history/electron-browser/history';
import { ActivitybarPart } from 'vs/workbench/browser/parts/activitybar/activitybarPart';
import { EditorPart } from 'vs/workbench/browser/parts/editor/editorPart';
import { SidebarPart } from 'vs/workbench/browser/parts/sidebar/sidebarPart';
@@ -38,7 +37,7 @@ import { IActionBarRegistry, Extensions as ActionBarExtensions } from 'vs/workbe
import { PanelRegistry, Extensions as PanelExtensions } from 'vs/workbench/browser/panel';
import { QuickOpenController } from 'vs/workbench/browser/parts/quickopen/quickOpenController';
import { getServices } from 'vs/platform/instantiation/common/extensions';
import { Position, Parts, IPartService, ILayoutOptions } from 'vs/workbench/services/part/common/partService';
import { Position, Parts, IPartService, ILayoutOptions, Dimension } from 'vs/workbench/services/part/common/partService';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { ContextMenuService } from 'vs/workbench/services/contextview/electron-browser/contextmenuService';
@@ -56,9 +55,8 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { ViewletService } from 'vs/workbench/services/viewlet/browser/viewletService';
import { RemoteFileService } from 'vs/workbench/services/files/electron-browser/remoteFileService';
import { IFileService } from 'vs/platform/files/common/files';
import { IListService, ListService } from 'vs/platform/list/browser/listService';
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
import { ConfigurationResolverService } from 'vs/workbench/services/configurationResolver/node/configurationResolverService';
import { ConfigurationResolverService } from 'vs/workbench/services/configurationResolver/electron-browser/configurationResolverService';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { ITitleService } from 'vs/workbench/services/title/common/titleService';
import { WorkbenchMessageService } from 'vs/workbench/services/message/browser/messageService';
@@ -79,7 +77,8 @@ import { ProgressService2 } from 'vs/workbench/services/progress/browser/progres
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { ILifecycleService, ShutdownReason } from 'vs/platform/lifecycle/common/lifecycle';
import { ShutdownReason, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { LifecycleService } from 'vs/workbench/services/lifecycle/electron-browser/lifecycleService';
import { IWindowService, IWindowConfiguration as IWindowSettings, IWindowConfiguration, IPath } from 'vs/platform/windows/common/windows';
import { IMessageService } from 'vs/platform/message/common/message';
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
@@ -87,7 +86,6 @@ import { IMenuService, SyncActionDescriptor } from 'vs/platform/actions/common/a
import { MenuService } from 'vs/platform/actions/common/menuService';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
import { OpenRecentAction, ToggleDevToolsAction, ReloadWindowAction, ShowPreviousWindowTab, MoveWindowTabToNewWindow, MergeAllWindowTabs, ShowNextWindowTab, ToggleWindowTabsBar } from 'vs/workbench/electron-browser/actions';
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
@@ -97,7 +95,9 @@ import { FileDecorationsService } from 'vs/workbench/services/decorations/browse
import { IDecorationsService } from 'vs/workbench/services/decorations/browser/decorations';
import { ActivityService } from 'vs/workbench/services/activity/browser/activityService';
import URI from 'vs/base/common/uri';
import { IListService, ListService } from 'vs/platform/list/browser/listService';
import { domEvent } from 'vs/base/browser/event';
import { InputFocusedContext } from 'vs/platform/workbench/common/contextkeys';
// {{SQL CARBON EDIT}}
import { IConnectionManagementService, IConnectionDialogService, IErrorMessageService, IServerGroupController } from 'sql/parts/connection/common/connectionManagement';
@@ -172,11 +172,6 @@ export interface IWorkbenchStartedInfo {
restoredEditors: string[];
}
export interface IWorkbenchCallbacks {
onServicesCreated?: () => void;
onWorkbenchStarted?: (info: IWorkbenchStartedInfo) => void;
}
const Identifiers = {
WORKBENCH_CONTAINER: 'workbench.main.container',
TITLEBAR_PART: 'workbench.parts.titlebar',
@@ -187,24 +182,32 @@ const Identifiers = {
STATUSBAR_PART: 'workbench.parts.statusbar'
};
function getWorkbenchStateString(state: WorkbenchState): string {
switch (state) {
case WorkbenchState.EMPTY: return 'empty';
case WorkbenchState.FOLDER: return 'folder';
case WorkbenchState.WORKSPACE: return 'workspace';
}
}
/**
* The workbench creates and lays out all parts that make up the workbench.
*/
export class Workbench implements IPartService {
private static sidebarHiddenSettingKey = 'workbench.sidebar.hidden';
private static sidebarRestoreSettingKey = 'workbench.sidebar.restore';
private static panelHiddenSettingKey = 'workbench.panel.hidden';
private static zenModeActiveSettingKey = 'workbench.zenmode.active';
private static readonly sidebarHiddenStorageKey = 'workbench.sidebar.hidden';
private static readonly sidebarRestoreStorageKey = 'workbench.sidebar.restore';
private static readonly panelHiddenStorageKey = 'workbench.panel.hidden';
private static readonly zenModeActiveStorageKey = 'workbench.zenmode.active';
private static readonly panelPositionStorageKey = 'workbench.panel.location';
private static sidebarPositionConfigurationKey = 'workbench.sideBar.location';
private static panelPositionConfigurationKey = 'workbench.panel.location';
private static statusbarVisibleConfigurationKey = 'workbench.statusBar.visible';
private static activityBarVisibleConfigurationKey = 'workbench.activityBar.visible';
private static readonly sidebarPositionConfigurationKey = 'workbench.sideBar.location';
private static readonly statusbarVisibleConfigurationKey = 'workbench.statusBar.visible';
private static readonly activityBarVisibleConfigurationKey = 'workbench.activityBar.visible';
private static closeWhenEmptyConfigurationKey = 'window.closeWhenEmpty';
private static readonly closeWhenEmptyConfigurationKey = 'window.closeWhenEmpty';
private static fontAliasingConfigurationKey = 'workbench.fontAliasing';
private static readonly fontAliasingConfigurationKey = 'workbench.fontAliasing';
private _onTitleBarVisibilityChange: Emitter<void>;
@@ -234,9 +237,6 @@ export class Workbench implements IPartService {
private workbenchLayout: WorkbenchLayout;
private toDispose: IDisposable[];
private toShutdown: { shutdown: () => void; }[];
private callbacks: IWorkbenchCallbacks;
private creationPromise: TPromise<boolean>;
private creationPromiseComplete: ValueCallback;
private sideBarHidden: boolean;
private statusBarHidden: boolean;
private activityBarHidden: boolean;
@@ -263,13 +263,12 @@ export class Workbench implements IPartService {
container: HTMLElement,
configuration: IWindowConfiguration,
serviceCollection: ServiceCollection,
private lifecycleService: LifecycleService,
@IInstantiationService private instantiationService: IInstantiationService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IStorageService private storageService: IStorageService,
@ILifecycleService private lifecycleService: ILifecycleService,
@IMessageService private messageService: IMessageService,
@IConfigurationService private configurationService: WorkspaceService,
@ITelemetryService private telemetryService: ITelemetryService,
@IEnvironmentService private environmentService: IEnvironmentService,
@IWindowService private windowService: IWindowService
) {
@@ -293,155 +292,165 @@ export class Workbench implements IPartService {
this.closeEmptyWindowScheduler = new RunOnceScheduler(() => this.onAllEditorsClosed(), 50);
this._onTitleBarVisibilityChange = new Emitter<void>();
this.creationPromise = new TPromise<boolean>(c => {
this.creationPromiseComplete = c;
});
}
public get onTitleBarVisibilityChange(): Event<void> {
return this._onTitleBarVisibilityChange.event;
}
public get onEditorLayout(): Event<void> {
return chain(this.editorPart.onLayout)
.map(() => void 0)
.event;
public get onEditorLayout(): Event<Dimension> {
return this.editorPart.onLayout;
}
/**
* Starts the workbench and creates the HTML elements on the container. A workbench can only be started
* once. Use the shutdown function to free up resources created by the workbench on startup.
*/
public startup(callbacks?: IWorkbenchCallbacks): void {
try {
this.workbenchStarted = true;
this.callbacks = callbacks;
public startup(): TPromise<IWorkbenchStartedInfo> {
this.workbenchStarted = true;
// Create Workbench
this.createWorkbench();
// Create Workbench Container
this.createWorkbench();
// Install some global actions
this.createGlobalActions();
// Install some global actions
this.createGlobalActions();
// Services
this.initServices();
if (this.callbacks && this.callbacks.onServicesCreated) {
this.callbacks.onServicesCreated();
// Services
this.initServices();
// Contexts
this.messagesVisibleContext = MessagesVisibleContext.bindTo(this.contextKeyService);
this.editorsVisibleContext = EditorsVisibleContext.bindTo(this.contextKeyService);
this.inZenMode = InZenModeContext.bindTo(this.contextKeyService);
this.sideBarVisibleContext = SidebarVisibleContext.bindTo(this.contextKeyService);
const inputFocused = InputFocusedContext.bindTo(this.contextKeyService);
const onWindowsFocusIn = domEvent(window, 'focusin', true);
onWindowsFocusIn(() => inputFocused.set(document.activeElement && (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA')), null, this.toDispose);
// Set workbench state context
const WorkbenchStateContext = new RawContextKey<string>('workbenchState', getWorkbenchStateString(this.configurationService.getWorkbenchState()));
const workbenchStateContext = WorkbenchStateContext.bindTo(this.contextKeyService);
const WorkspaceFolderCountContext = new RawContextKey<number>('workspaceFolderCount', this.configurationService.getWorkspace().folders.length);
const workspaceFolderCountContext = WorkspaceFolderCountContext.bindTo(this.contextKeyService);
this.toDispose.push(this.configurationService.onDidChangeWorkbenchState(() => workbenchStateContext.set(getWorkbenchStateString(this.configurationService.getWorkbenchState()))));
this.toDispose.push(this.configurationService.onDidChangeWorkspaceFolders(() => workspaceFolderCountContext.set(this.configurationService.getWorkspace().folders.length)));
// Register Listeners
this.registerListeners();
// Settings
this.initSettings();
// Create Workbench and Parts
this.renderWorkbench();
// Workbench Layout
this.createWorkbenchLayout();
// Restore Parts
return this.restoreParts();
}
private createWorkbench(): void {
this.workbenchContainer = $('.monaco-workbench-container');
this.workbench = $().div({
'class': `monaco-workbench ${isWindows ? 'windows' : isLinux ? 'linux' : 'mac'}`,
id: Identifiers.WORKBENCH_CONTAINER
}).appendTo(this.workbenchContainer);
}
private restoreParts(): TPromise<IWorkbenchStartedInfo> {
const restorePromises: TPromise<any>[] = [];
// Restore Editors
const editorRestoreStopWatch = StopWatch.create();
const editorRestoreClock = time('restore:editors');
const restoredEditors: string[] = [];
restorePromises.push(this.resolveEditorsToOpen().then(inputs => {
let editorOpenPromise: TPromise<IEditor[]>;
if (inputs.length) {
editorOpenPromise = this.editorService.openEditors(inputs.map(input => { return { input, position: EditorPosition.ONE }; }));
} else {
editorOpenPromise = this.editorPart.restoreEditors();
}
// Contexts
this.messagesVisibleContext = MessagesVisibleContext.bindTo(this.contextKeyService);
this.editorsVisibleContext = EditorsVisibleContext.bindTo(this.contextKeyService);
this.inZenMode = InZenModeContext.bindTo(this.contextKeyService);
this.sideBarVisibleContext = SidebarVisibleContext.bindTo(this.contextKeyService);
// update lifecycle *after* triggering the editor restore
this.lifecycleService.phase = LifecyclePhase.Restoring;
// Register Listeners
this.registerListeners();
return editorOpenPromise.then(editors => {
this.handleEditorBackground(); // make sure we show the proper background in the editor area
// Settings
this.initSettings();
editorRestoreClock.stop();
editorRestoreStopWatch.stop();
// Create Workbench and Parts
this.renderWorkbench();
// Workbench Layout
this.createWorkbenchLayout();
// Load composites and editors in parallel
const compositeAndEditorPromises: TPromise<any>[] = [];
// Restore last opened viewlet
let viewletRestoreStopWatch: StopWatch;
let viewletIdToRestore: string;
if (!this.sideBarHidden) {
this.sideBarVisibleContext.set(true);
if (this.shouldRestoreLastOpenedViewlet()) {
viewletIdToRestore = this.storageService.get(SidebarPart.activeViewletSettingsKey, StorageScope.WORKSPACE);
}
if (!viewletIdToRestore) {
viewletIdToRestore = this.viewletService.getDefaultViewletId();
}
viewletRestoreStopWatch = StopWatch.create();
const viewletTimer = startTimer('restore:viewlet');
compositeAndEditorPromises.push(viewletTimer.while(this.viewletService.openViewlet(viewletIdToRestore)).then(() => {
viewletRestoreStopWatch.stop();
}));
}
// Load Panel
const panelRegistry = Registry.as<PanelRegistry>(PanelExtensions.Panels);
const panelId = this.storageService.get(PanelPart.activePanelSettingsKey, StorageScope.WORKSPACE, panelRegistry.getDefaultPanelId());
if (!this.panelHidden && !!panelId) {
compositeAndEditorPromises.push(this.panelPart.openPanel(panelId, false));
}
// Load Editors
const editorRestoreStopWatch = StopWatch.create();
const restoredEditors: string[] = [];
const editorsTimer = startTimer('restore:editors');
compositeAndEditorPromises.push(editorsTimer.while(this.resolveEditorsToOpen().then(inputs => {
let editorOpenPromise: TPromise<IEditor[]>;
if (inputs.length) {
editorOpenPromise = this.editorService.openEditors(inputs.map(input => { return { input, position: EditorPosition.ONE }; }));
} else {
editorOpenPromise = this.editorPart.restoreEditors();
}
return editorOpenPromise.then(editors => {
this.handleEditorBackground(); // make sure we show the proper background in the editor area
editorRestoreStopWatch.stop();
for (const editor of editors) {
if (editor) {
if (editor.input) {
restoredEditors.push(editor.input.getName());
} else {
restoredEditors.push(`other:${editor.getId()}`);
}
for (const editor of editors) {
if (editor) {
if (editor.input) {
restoredEditors.push(editor.input.getName());
} else {
restoredEditors.push(`other:${editor.getId()}`);
}
}
});
})));
}
});
}));
if (this.storageService.getBoolean(Workbench.zenModeActiveSettingKey, StorageScope.WORKSPACE, false)) {
this.toggleZenMode(true);
// Restore Sidebar
let viewletRestoreStopWatch: StopWatch;
let viewletIdToRestore: string;
if (!this.sideBarHidden) {
this.sideBarVisibleContext.set(true);
if (this.shouldRestoreLastOpenedViewlet()) {
viewletIdToRestore = this.storageService.get(SidebarPart.activeViewletSettingsKey, StorageScope.WORKSPACE);
}
// Flag workbench as created once done
const workbenchDone = (error?: Error) => {
this.workbenchCreated = true;
this.creationPromiseComplete(true);
if (!viewletIdToRestore) {
viewletIdToRestore = this.viewletService.getDefaultViewletId();
}
if (this.callbacks && this.callbacks.onWorkbenchStarted) {
this.callbacks.onWorkbenchStarted({
customKeybindingsCount: this.keybindingService.customKeybindingsCount(),
restoreViewletDuration: viewletRestoreStopWatch ? Math.round(viewletRestoreStopWatch.elapsed()) : 0,
restoreEditorsDuration: Math.round(editorRestoreStopWatch.elapsed()),
pinnedViewlets: this.activitybarPart.getPinned(),
restoredViewlet: viewletIdToRestore,
restoredEditors
});
}
if (error) {
errors.onUnexpectedError(error);
}
};
// Join viewlet, panel and editor promises
TPromise.join(compositeAndEditorPromises).then(() => workbenchDone(), error => workbenchDone(error));
} catch (error) {
// Print out error
console.error(toErrorMessage(error, true));
// Rethrow
throw error;
viewletRestoreStopWatch = StopWatch.create();
const viewletRestoreClock = time('restore:viewlet');
restorePromises.push(this.viewletService.openViewlet(viewletIdToRestore).then(() => {
viewletRestoreStopWatch.stop();
viewletRestoreClock.stop();
}));
}
// Restore Panel
const panelRegistry = Registry.as<PanelRegistry>(PanelExtensions.Panels);
const panelId = this.storageService.get(PanelPart.activePanelSettingsKey, StorageScope.WORKSPACE, panelRegistry.getDefaultPanelId());
if (!this.panelHidden && !!panelId) {
restorePromises.push(this.panelPart.openPanel(panelId, false));
}
// Restore Zen Mode if active
if (this.storageService.getBoolean(Workbench.zenModeActiveStorageKey, StorageScope.WORKSPACE, false)) {
this.toggleZenMode(true);
}
const onRestored = (error?: Error): IWorkbenchStartedInfo => {
this.workbenchCreated = true;
if (error) {
errors.onUnexpectedError(error);
}
return {
customKeybindingsCount: this.keybindingService.customKeybindingsCount(),
restoreViewletDuration: viewletRestoreStopWatch ? Math.round(viewletRestoreStopWatch.elapsed()) : 0,
restoreEditorsDuration: Math.round(editorRestoreStopWatch.elapsed()),
pinnedViewlets: this.activitybarPart.getPinned(),
restoredViewlet: viewletIdToRestore,
restoredEditors
};
};
return TPromise.join(restorePromises).then(() => onRestored(), error => onRestored(error));
}
private createGlobalActions(): void {
@@ -454,7 +463,7 @@ export class Workbench implements IPartService {
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(OpenRecentAction, OpenRecentAction.ID, OpenRecentAction.LABEL, { primary: isDeveloping ? null : KeyMod.CtrlCmd | KeyCode.KEY_R, mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_R } }), 'File: Open Recent...', localize('file', "File"));
// Actions for macOS native tabs management (only when enabled)
const windowConfig = this.configurationService.getConfiguration<IWindowConfiguration>();
const windowConfig = this.configurationService.getValue<IWindowConfiguration>();
if (windowConfig && windowConfig.window && windowConfig.window.nativeTabs) {
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowPreviousWindowTab, ShowPreviousWindowTab.ID, ShowPreviousWindowTab.LABEL), 'Show Previous Window Tab');
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowNextWindowTab, ShowNextWindowTab.ID, ShowNextWindowTab.LABEL), 'Show Next Window Tab');
@@ -658,6 +667,7 @@ export class Workbench implements IPartService {
this.toDispose.push(this.quickOpen);
this.toShutdown.push(this.quickOpen);
serviceCollection.set(IQuickOpenService, this.quickOpen);
// {{SQL CARBON EDIT}}
// SQL Tools services
serviceCollection.set(IAngularEventingService, this.instantiationService.createInstance(AngularEventingService));
@@ -697,7 +707,7 @@ export class Workbench implements IPartService {
this.toDispose.push(connectionManagementService);
this.toShutdown.push(connectionManagementService);
this.toShutdown.push(accountManagementService);
// Contributed services
const contributedServices = getServices();
for (let contributedService of contributedServices) {
@@ -706,7 +716,7 @@ export class Workbench implements IPartService {
// Set the some services to registries that have been created eagerly
Registry.as<IActionBarRegistry>(ActionBarExtensions.Actionbar).setInstantiationService(this.instantiationService);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).setInstantiationService(this.instantiationService);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).start(this.instantiationService, this.lifecycleService);
Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).setInstantiationService(this.instantiationService);
this.instantiationService.createInstance(DefaultConfigurationExportHelper);
@@ -717,11 +727,11 @@ export class Workbench implements IPartService {
private initSettings(): void {
// Sidebar visibility
this.sideBarHidden = this.storageService.getBoolean(Workbench.sidebarHiddenSettingKey, StorageScope.WORKSPACE, this.contextService.getWorkbenchState() === WorkbenchState.EMPTY);
this.sideBarHidden = this.storageService.getBoolean(Workbench.sidebarHiddenStorageKey, StorageScope.WORKSPACE, this.contextService.getWorkbenchState() === WorkbenchState.EMPTY);
// Panel part visibility
const panelRegistry = Registry.as<PanelRegistry>(PanelExtensions.Panels);
this.panelHidden = this.storageService.getBoolean(Workbench.panelHiddenSettingKey, StorageScope.WORKSPACE, true);
this.panelHidden = this.storageService.getBoolean(Workbench.panelHiddenStorageKey, StorageScope.WORKSPACE, true);
if (!panelRegistry.getDefaultPanelId()) {
this.panelHidden = true; // we hide panel part if there is no default panel
}
@@ -731,7 +741,7 @@ export class Workbench implements IPartService {
this.sideBarPosition = (sideBarPosition === 'right') ? Position.RIGHT : Position.LEFT;
// Panel position
const panelPosition = this.configurationService.getValue<string>(Workbench.panelPositionConfigurationKey);
const panelPosition = this.storageService.get(Workbench.panelPositionStorageKey, StorageScope.WORKSPACE, 'bottom');
this.panelPosition = (panelPosition === 'right') ? Position.RIGHT : Position.BOTTOM;
// Statusbar visibility
@@ -768,10 +778,6 @@ export class Workbench implements IPartService {
return this.workbenchCreated && this.workbenchStarted;
}
public joinCreation(): TPromise<boolean> {
return this.creationPromise;
}
public hasFocus(part: Parts): boolean {
const activeElement = document.activeElement;
if (!activeElement) {
@@ -845,7 +851,7 @@ export class Workbench implements IPartService {
return null; // not enabled when developing due to https://github.com/electron/electron/issues/3647
}
const windowConfig = this.configurationService.getConfiguration<IWindowSettings>();
const windowConfig = this.configurationService.getValue<IWindowSettings>();
if (windowConfig && windowConfig.window) {
const useNativeTabs = windowConfig.window.nativeTabs;
if (useNativeTabs) {
@@ -857,6 +863,7 @@ export class Workbench implements IPartService {
return style;
}
}
// {{SQL CARBON EDIT}}
*/
return null;
@@ -894,7 +901,7 @@ export class Workbench implements IPartService {
}
// If sidebar becomes hidden, also hide the current active Viewlet if any
let promise = TPromise.as<any>(null);
let promise = TPromise.wrap<any>(null);
if (hidden && this.sidebarPart.getActiveViewlet()) {
promise = this.sidebarPart.hideActiveViewlet().then(() => {
const activeEditor = this.editorPart.getActiveEditor();
@@ -922,9 +929,9 @@ export class Workbench implements IPartService {
// Remember in settings
const defaultHidden = this.contextService.getWorkbenchState() === WorkbenchState.EMPTY;
if (hidden !== defaultHidden) {
this.storageService.store(Workbench.sidebarHiddenSettingKey, hidden ? 'true' : 'false', StorageScope.WORKSPACE);
this.storageService.store(Workbench.sidebarHiddenStorageKey, hidden ? 'true' : 'false', StorageScope.WORKSPACE);
} else {
this.storageService.remove(Workbench.sidebarHiddenSettingKey, StorageScope.WORKSPACE);
this.storageService.remove(Workbench.sidebarHiddenStorageKey, StorageScope.WORKSPACE);
}
// Layout
@@ -945,7 +952,7 @@ export class Workbench implements IPartService {
}
// If panel part becomes hidden, also hide the current active panel if any
let promise = TPromise.as<any>(null);
let promise = TPromise.wrap<any>(null);
if (hidden && this.panelPart.getActivePanel()) {
promise = this.panelPart.hideActivePanel().then(() => {
// Pass Focus to Editor if Panel part is now hidden
@@ -968,9 +975,9 @@ export class Workbench implements IPartService {
// Remember in settings
if (!hidden) {
this.storageService.store(Workbench.panelHiddenSettingKey, 'false', StorageScope.WORKSPACE);
this.storageService.store(Workbench.panelHiddenStorageKey, 'false', StorageScope.WORKSPACE);
} else {
this.storageService.remove(Workbench.panelHiddenSettingKey, StorageScope.WORKSPACE);
this.storageService.remove(Workbench.panelHiddenStorageKey, StorageScope.WORKSPACE);
}
// Layout
@@ -981,7 +988,7 @@ export class Workbench implements IPartService {
}
public toggleMaximizedPanel(): void {
this.workbenchLayout.layout({ toggleMaximizedPanel: true });
this.workbenchLayout.layout({ toggleMaximizedPanel: true, source: Parts.PANEL_PART });
}
public isPanelMaximized(): boolean {
@@ -992,9 +999,9 @@ export class Workbench implements IPartService {
return this.sideBarPosition;
}
private setSideBarPosition(position: Position): void {
public setSideBarPosition(position: Position): void {
if (this.sideBarHidden) {
this.setSideBarHidden(false, true /* Skip Layout */).done(undefined, errors.onUnexpectedError);
this.setSideBarHidden(false, true /* Skip Layout */).done(void 0, errors.onUnexpectedError);
}
const newPositionValue = (position === Position.LEFT) ? 'left' : 'right';
@@ -1019,24 +1026,23 @@ export class Workbench implements IPartService {
return this.panelPosition;
}
private setPanelPosition(position: Position): void {
if (this.panelHidden) {
this.setPanelHidden(false, true /* Skip Layout */).done(undefined, errors.onUnexpectedError);
}
public setPanelPosition(position: Position): TPromise<void> {
return (this.panelHidden ? this.setPanelHidden(false, true /* Skip Layout */) : TPromise.as(undefined)).then(() => {
const newPositionValue = (position === Position.BOTTOM) ? 'bottom' : 'right';
const oldPositionValue = (this.panelPosition === Position.BOTTOM) ? 'bottom' : 'right';
this.panelPosition = position;
this.storageService.store(Workbench.panelPositionStorageKey, Position[this.panelPosition].toLowerCase(), StorageScope.WORKSPACE);
const newPositionValue = (position === Position.BOTTOM) ? 'bottom' : 'right';
const oldPositionValue = (this.panelPosition === Position.BOTTOM) ? 'bottom' : 'right';
this.panelPosition = position;
// Adjust CSS
this.panelPart.getContainer().removeClass(oldPositionValue);
this.panelPart.getContainer().addClass(newPositionValue);
// Adjust CSS
this.panelPart.getContainer().removeClass(oldPositionValue);
this.panelPart.getContainer().addClass(newPositionValue);
// Update Styles
this.panelPart.updateStyles();
// Update Styles
this.panelPart.updateStyles();
// Layout
this.workbenchLayout.layout();
// Layout
this.workbenchLayout.layout();
});
}
private setFontAliasing(aliasing: string) {
@@ -1068,16 +1074,16 @@ export class Workbench implements IPartService {
// Restore sidebar if we are being shutdown as a matter of a reload
if (reason === ShutdownReason.RELOAD) {
this.storageService.store(Workbench.sidebarRestoreSettingKey, 'true', StorageScope.WORKSPACE);
this.storageService.store(Workbench.sidebarRestoreStorageKey, 'true', StorageScope.WORKSPACE);
}
// Preserve zen mode only on reload. Real quit gets out of zen mode so novice users do not get stuck in zen mode.
const zenConfig = this.configurationService.getConfiguration<IZenModeSettings>('zenMode');
const zenConfig = this.configurationService.getValue<IZenModeSettings>('zenMode');
const zenModeActive = (zenConfig.restore || reason === ShutdownReason.RELOAD) && this.zenMode.active;
if (zenModeActive) {
this.storageService.store(Workbench.zenModeActiveSettingKey, true, StorageScope.WORKSPACE);
this.storageService.store(Workbench.zenModeActiveStorageKey, true, StorageScope.WORKSPACE);
} else {
this.storageService.remove(Workbench.zenModeActiveSettingKey, StorageScope.WORKSPACE);
this.storageService.remove(Workbench.zenModeActiveStorageKey, StorageScope.WORKSPACE);
}
// Pass shutdown on to each participant
@@ -1194,12 +1200,6 @@ export class Workbench implements IPartService {
this.setSideBarPosition(newSidebarPosition);
}
const newPanelPositionValue = this.configurationService.getValue<string>(Workbench.panelPositionConfigurationKey);
const newPanelPosition = (newPanelPositionValue === 'right') ? Position.RIGHT : Position.BOTTOM;
if (newPanelPosition !== this.getPanelPosition()) {
this.setPanelPosition(newPanelPosition);
}
const fontAliasing = this.configurationService.getValue<string>(Workbench.fontAliasingConfigurationKey);
if (fontAliasing !== this.fontAliasing) {
this.setFontAliasing(fontAliasing);
@@ -1236,13 +1236,6 @@ export class Workbench implements IPartService {
this.toDispose.push(this.workbenchLayout);
}
private createWorkbench(): void {
// Create Workbench DIV Off-DOM
this.workbenchContainer = $('.monaco-workbench-container');
this.workbench = $().div({ 'class': 'monaco-workbench ' + (isWindows ? 'windows' : isLinux ? 'linux' : 'mac'), id: Identifiers.WORKBENCH_CONTAINER }).appendTo(this.workbenchContainer);
}
private renderWorkbench(): void {
// Apply sidebar state as CSS class
@@ -1343,18 +1336,6 @@ export class Workbench implements IPartService {
this.statusbarPart.create(statusbarContainer);
}
public getEditorPart(): EditorPart {
return this.editorPart;
}
public getSidebarPart(): SidebarPart {
return this.sidebarPart;
}
public getPanelPart(): PanelPart {
return this.panelPart;
}
public getInstantiationService(): IInstantiationService {
return this.instantiationService;
}
@@ -1381,13 +1362,13 @@ export class Workbench implements IPartService {
// Check if zen mode transitioned to full screen and if now we are out of zen mode -> we need to go out of full screen
let toggleFullScreen = false;
if (this.zenMode.active) {
const config = this.configurationService.getConfiguration<IZenModeSettings>('zenMode');
const config = this.configurationService.getValue<IZenModeSettings>('zenMode');
toggleFullScreen = !browser.isFullscreen() && config.fullScreen;
this.zenMode.transitionedToFullScreen = toggleFullScreen;
this.zenMode.wasSideBarVisible = this.isVisible(Parts.SIDEBAR_PART);
this.zenMode.wasPanelVisible = this.isVisible(Parts.PANEL_PART);
this.setPanelHidden(true, true).done(undefined, errors.onUnexpectedError);
this.setSideBarHidden(true, true).done(undefined, errors.onUnexpectedError);
this.setPanelHidden(true, true).done(void 0, errors.onUnexpectedError);
this.setSideBarHidden(true, true).done(void 0, errors.onUnexpectedError);
if (config.hideActivityBar) {
this.setActivityBarHidden(true, true);
@@ -1402,11 +1383,11 @@ export class Workbench implements IPartService {
}
} else {
if (this.zenMode.wasPanelVisible) {
this.setPanelHidden(false, true).done(undefined, errors.onUnexpectedError);
this.setPanelHidden(false, true).done(void 0, errors.onUnexpectedError);
}
if (this.zenMode.wasSideBarVisible) {
this.setSideBarHidden(false, true).done(undefined, errors.onUnexpectedError);
this.setSideBarHidden(false, true).done(void 0, errors.onUnexpectedError);
}
// Status bar and activity bar visibility come from settings -> update their visibility.
@@ -1427,7 +1408,7 @@ export class Workbench implements IPartService {
}
if (toggleFullScreen) {
this.windowService.toggleFullScreen().done(undefined, errors.onUnexpectedError);
this.windowService.toggleFullScreen().done(void 0, errors.onUnexpectedError);
}
}
@@ -1451,9 +1432,9 @@ export class Workbench implements IPartService {
return true; // always restore sidebar when we are in development mode
}
const restore = this.storageService.getBoolean(Workbench.sidebarRestoreSettingKey, StorageScope.WORKSPACE);
const restore = this.storageService.getBoolean(Workbench.sidebarRestoreStorageKey, StorageScope.WORKSPACE);
if (restore) {
this.storageService.remove(Workbench.sidebarRestoreSettingKey, StorageScope.WORKSPACE); // only support once
this.storageService.remove(Workbench.sidebarRestoreStorageKey, StorageScope.WORKSPACE); // only support once
}
return restore;