Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 (#7880)

* Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998

* fix pipelines

* fix strict-null-checks

* add missing files
This commit is contained in:
Anthony Dresser
2019-10-21 22:12:22 -07:00
committed by GitHub
parent 7c9be74970
commit 1e22f47304
913 changed files with 18898 additions and 16536 deletions

View File

@@ -21,9 +21,9 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { ITitleService } from 'vs/workbench/services/title/common/titleService';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { LifecyclePhase, StartupKind, ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { MenuBarVisibility, getTitleBarStyle } from 'vs/platform/windows/common/windows';
import { MenuBarVisibility, getTitleBarStyle, getMenuBarVisibility } from 'vs/platform/windows/common/windows';
import { IHostService } from 'vs/workbench/services/host/browser/host';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IEditorService, IResourceEditor } from 'vs/workbench/services/editor/common/editorService';
@@ -36,9 +36,10 @@ import { IActivityBarService } from 'vs/workbench/services/activityBar/browser/a
import { IFileService } from 'vs/platform/files/common/files';
import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
import { coalesce } from 'vs/base/common/arrays';
import { assertIsDefined } from 'vs/base/common/types';
import { INotificationService, NotificationsFilter } from 'vs/platform/notification/common/notification';
enum Settings {
MENUBAR_VISIBLE = 'window.menuBarVisibility',
ACTIVITYBAR_VISIBLE = 'workbench.activityBar.visible',
STATUSBAR_VISIBLE = 'workbench.statusBar.visible',
@@ -46,7 +47,6 @@ enum Settings {
PANEL_POSITION = 'workbench.panel.defaultLocation',
ZEN_MODE_RESTORE = 'zenMode.restore',
}
enum Storage {
@@ -83,9 +83,6 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
//#region Events
private readonly _onTitleBarVisibilityChange: Emitter<void> = this._register(new Emitter<void>());
readonly onTitleBarVisibilityChange: Event<void> = this._onTitleBarVisibilityChange.event;
private readonly _onZenModeChange: Emitter<boolean> = this._register(new Emitter<boolean>());
readonly onZenModeChange: Event<boolean> = this._onZenModeChange.event;
@@ -98,12 +95,15 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
private readonly _onPanelPositionChange: Emitter<string> = this._register(new Emitter<string>());
readonly onPanelPositionChange: Event<string> = this._onPanelPositionChange.event;
private readonly _onPartVisibilityChange: Emitter<void> = this._register(new Emitter<void>());
readonly onPartVisibilityChange: Event<void> = this._onPartVisibilityChange.event;
private readonly _onLayout = this._register(new Emitter<IDimension>());
readonly onLayout: Event<IDimension> = this._onLayout.event;
//#endregion
private _dimension: IDimension;
private _dimension!: IDimension;
get dimension(): IDimension { return this._dimension; }
private _container: HTMLElement = document.createElement('div');
@@ -111,29 +111,30 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
private parts: Map<string, Part> = new Map<string, Part>();
private workbenchGrid: SerializableGrid<ISerializableView>;
private workbenchGrid!: SerializableGrid<ISerializableView>;
private disposed: boolean;
private disposed: boolean | undefined;
private titleBarPartView: ISerializableView;
private activityBarPartView: ISerializableView;
private sideBarPartView: ISerializableView;
private panelPartView: ISerializableView;
private editorPartView: ISerializableView;
private statusBarPartView: ISerializableView;
private titleBarPartView!: ISerializableView;
private activityBarPartView!: ISerializableView;
private sideBarPartView!: ISerializableView;
private panelPartView!: ISerializableView;
private editorPartView!: ISerializableView;
private statusBarPartView!: ISerializableView;
private environmentService: IWorkbenchEnvironmentService;
private configurationService: IConfigurationService;
private lifecycleService: ILifecycleService;
private storageService: IStorageService;
private hostService: IHostService;
private editorService: IEditorService;
private editorGroupService: IEditorGroupsService;
private panelService: IPanelService;
private titleService: ITitleService;
private viewletService: IViewletService;
private contextService: IWorkspaceContextService;
private backupFileService: IBackupFileService;
private environmentService!: IWorkbenchEnvironmentService;
private configurationService!: IConfigurationService;
private lifecycleService!: ILifecycleService;
private storageService!: IStorageService;
private hostService!: IHostService;
private editorService!: IEditorService;
private editorGroupService!: IEditorGroupsService;
private panelService!: IPanelService;
private titleService!: ITitleService;
private viewletService!: IViewletService;
private contextService!: IWorkspaceContextService;
private backupFileService!: IBackupFileService;
private notificationService!: INotificationService;
protected readonly state = {
fullscreen: false,
@@ -181,7 +182,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
transitionedToCenteredEditorLayout: false,
wasSideBarVisible: false,
wasPanelVisible: false,
transitionDisposables: new DisposableStore()
transitionDisposables: new DisposableStore(),
setNotificationsFilter: false
},
};
@@ -209,6 +211,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
this.panelService = accessor.get(IPanelService);
this.viewletService = accessor.get(IViewletService);
this.titleService = accessor.get(ITitleService);
this.notificationService = accessor.get(INotificationService);
accessor.get(IStatusbarService); // not used, but called to ensure instantiated
accessor.get(IActivityBarService); // not used, but called to ensure instantiated
@@ -261,8 +264,6 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
this.state.menuBar.toggled = visible;
if (this.state.fullscreen && (this.state.menuBar.visibility === 'toggle' || this.state.menuBar.visibility === 'default')) {
this._onTitleBarVisibilityChange.fire();
// Propagate to grid
this.workbenchGrid.setViewVisible(this.titleBarPartView, this.isVisible(Parts.TITLEBAR_PART));
@@ -287,8 +288,6 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
// Changing fullscreen state of the window has an impact on custom title bar visibility, so we need to update
if (getTitleBarStyle(this.configurationService, this.environmentService) === 'custom') {
this._onTitleBarVisibilityChange.fire();
// Propagate to grid
this.workbenchGrid.setViewVisible(this.titleBarPartView, this.isVisible(Parts.TITLEBAR_PART));
@@ -326,7 +325,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
}
// Menubar visibility
const newMenubarVisibility = this.configurationService.getValue<MenuBarVisibility>(Settings.MENUBAR_VISIBLE);
const newMenubarVisibility = getMenuBarVisibility(this.configurationService, this.environmentService);
this.setMenubarVisibility(newMenubarVisibility, !!skipLayout);
}
@@ -340,10 +339,12 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
this.state.sideBar.position = position;
// Adjust CSS
removeClass(activityBar.getContainer(), oldPositionValue);
removeClass(sideBar.getContainer(), oldPositionValue);
addClass(activityBar.getContainer(), newPositionValue);
addClass(sideBar.getContainer(), newPositionValue);
const activityBarContainer = assertIsDefined(activityBar.getContainer());
const sideBarContainer = assertIsDefined(sideBar.getContainer());
removeClass(activityBarContainer, oldPositionValue);
removeClass(sideBarContainer, oldPositionValue);
addClass(activityBarContainer, newPositionValue);
addClass(sideBarContainer, newPositionValue);
// Update Styles
activityBar.updateStyles();
@@ -371,7 +372,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
this.state.fullscreen = isFullscreen();
// Menubar visibility
this.state.menuBar.visibility = this.configurationService.getValue<MenuBarVisibility>(Settings.MENUBAR_VISIBLE);
this.state.menuBar.visibility = getMenuBarVisibility(this.configurationService, this.environmentService);
// Activity bar visibility
this.state.activityBar.hidden = !this.configurationService.getValue<string>(Settings.ACTIVITYBAR_VISIBLE);
@@ -455,7 +456,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
// Files to diff is exclusive
return pathsToEditors(configuration.filesToDiff, fileService).then(filesToDiff => {
if (filesToDiff && filesToDiff.length === 2) {
if (filesToDiff?.length === 2) {
return [{
leftResource: filesToDiff[0].resource,
rightResource: filesToDiff[1].resource,
@@ -528,10 +529,10 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
const container = this.getContainer(part);
return isAncestor(activeElement, container);
return !!container && isAncestor(activeElement, container);
}
getContainer(part: Parts): HTMLElement {
getContainer(part: Parts): HTMLElement | undefined {
switch (part) {
case Parts.TITLEBAR_PART:
return this.getPart(Parts.TITLEBAR_PART).getContainer();
@@ -579,7 +580,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
return true; // any other part cannot be hidden
}
getDimension(part: Parts): Dimension {
getDimension(part: Parts): Dimension | undefined {
return this.getPart(part).dimension;
}
@@ -647,6 +648,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
hideActivityBar: boolean;
hideStatusBar: boolean;
hideLineNumbers: boolean;
silentNotifications: boolean;
} = this.configurationService.getValue('zenMode');
toggleFullScreen = !this.state.fullscreen && config.fullScreen;
@@ -676,6 +678,11 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
this.state.zenMode.transitionDisposables.add(this.editorGroupService.enforcePartOptions({ showTabs: false }));
}
this.state.zenMode.setNotificationsFilter = config.silentNotifications;
if (config.silentNotifications) {
this.notificationService.setFilter(NotificationsFilter.ERROR);
}
if (config.centerLayout) {
this.centerEditorLayout(true, true);
}
@@ -701,6 +708,9 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
this.doUpdateLayoutConfiguration(true);
this.editorGroupService.activeGroup.focus();
if (this.state.zenMode.setNotificationsFilter) {
this.notificationService.setFilter(NotificationsFilter.OFF);
}
toggleFullScreen = this.state.zenMode.transitionedToFullScreen && this.state.fullscreen;
}
@@ -747,7 +757,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
this.workbenchGrid.setViewVisible(this.statusBarPartView, !hidden);
}
protected createWorkbenchLayout(instantiationService: IInstantiationService): void {
protected createWorkbenchLayout(): void {
const titleBar = this.getPart(Parts.TITLEBAR_PART);
const editorPart = this.getPart(Parts.EDITOR_PART);
const activityBar = this.getPart(Parts.ACTIVITYBAR_PART);
@@ -782,17 +792,18 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
this.container.prepend(workbenchGrid.element);
this.workbenchGrid = workbenchGrid;
this._register((this.sideBarPartView as SidebarPart).onDidVisibilityChange((visible) => {
this.setSideBarHidden(!visible, true);
}));
this._register((this.panelPartView as PanelPart).onDidVisibilityChange((visible) => {
this.setPanelHidden(!visible, true);
}));
this._register((this.editorPartView as PanelPart).onDidVisibilityChange((visible) => {
this.setEditorHidden(!visible, true);
}));
[titleBar, editorPart, activityBar, panelPart, sideBar, statusBar].forEach((part: Part) => {
this._register(part.onDidVisibilityChange((visible) => {
this._onPartVisibilityChange.fire();
if (part === sideBar) {
this.setSideBarHidden(!visible, true);
} else if (part === panelPart) {
this.setPanelHidden(!visible, true);
} else if (part === editorPart) {
this.setEditorHidden(!visible, true);
}
}));
});
this._register(this.storageService.onWillSaveState(() => {
const grid = this.workbenchGrid as SerializableGrid<ISerializableView>;
@@ -1121,8 +1132,9 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
this.storageService.store(Storage.PANEL_POSITION, positionToString(this.state.panel.position), StorageScope.WORKSPACE);
// Adjust CSS
removeClass(panelPart.getContainer(), oldPositionValue);
addClass(panelPart.getContainer(), newPositionValue);
const panelContainer = assertIsDefined(panelPart.getContainer());
removeClass(panelContainer, oldPositionValue);
addClass(panelContainer, newPositionValue);
// Update Styles
panelPart.updateStyles();
@@ -1161,7 +1173,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
const width = this.storageService.getNumber(Storage.GRID_WIDTH, StorageScope.GLOBAL, workbenchDimensions.width);
const height = this.storageService.getNumber(Storage.GRID_HEIGHT, StorageScope.GLOBAL, workbenchDimensions.height);
// At some point, we will not fall back to old keys from legacy layout, but for now, let's migrate the keys
const sideBarSize = this.storageService.getNumber(Storage.SIDEBAR_SIZE, StorageScope.GLOBAL, this.storageService.getNumber('workbench.sidebar.width', StorageScope.GLOBAL, Math.min(workbenchDimensions.width / 4, 300))!);
const sideBarSize = this.storageService.getNumber(Storage.SIDEBAR_SIZE, StorageScope.GLOBAL, this.storageService.getNumber('workbench.sidebar.width', StorageScope.GLOBAL, Math.min(workbenchDimensions.width / 4, 300)));
const panelSize = this.storageService.getNumber(Storage.PANEL_SIZE, StorageScope.GLOBAL, this.storageService.getNumber(this.state.panel.position === Position.BOTTOM ? 'workbench.panel.height' : 'workbench.panel.width', StorageScope.GLOBAL, workbenchDimensions.height / 3));
const titleBarHeight = this.titleBarPartView.minimumHeight;