Skip to content

Commit

Permalink
save parts splash on editor layout change microsoft#55017
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jul 26, 2018
1 parent 2da55bb commit c412116
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/vs/workbench/electron-browser/bootstrap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ function showPartsSplash(configuration) {
const splash = document.createElement('div');
splash.id = data.id;
const { layoutInfo, colorInfo } = data;

// ensure there is enough space
layoutInfo.sideBarWidth = Math.min(layoutInfo.sideBarWidth, window.innerWidth - (layoutInfo.activityBarWidth + layoutInfo.editorPartMinWidth));

if (configuration.folderUri || configuration.workspace) {
// folder or workspace -> status bar color, sidebar
splash.innerHTML = `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,28 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { Extensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
import * as themes from 'vs/workbench/common/theme';
import { IPartService, Parts, Position } from 'vs/workbench/services/part/common/partService';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { debounceEvent } from 'vs/base/common/event';
import { DEFAULT_EDITOR_MIN_DIMENSIONS } from 'vs/workbench/browser/parts/editor/editor';

class PartsSplash {

private static readonly _splashElementId = 'monaco-parts-splash';

private readonly _disposables: IDisposable[] = [];

constructor(
@IThemeService private readonly _themeService: IThemeService,
@IPartService private readonly _partService: IPartService,
@IStorageService private readonly _storageService: IStorageService,
@ILifecycleService lifecycleService: ILifecycleService,
) {
lifecycleService.when(LifecyclePhase.Running).then(_ => this._removePartsSplash());
lifecycleService.onShutdown(() => this._savePartsSplash());
debounceEvent(_partService.onEditorLayout, () => { }, 50)(this._savePartsSplash, this, this._disposables);
}

dispose(): void {
dispose(this._disposables);
}

private _savePartsSplash() {
Expand All @@ -38,8 +47,9 @@ class PartsSplash {
statusBarNoFolderBackground: theme.getColor(themes.STATUS_BAR_NO_FOLDER_BACKGROUND).toString(),
};
const layoutInfo = {
titleBarHeight: getTotalHeight(this._partService.getContainer(Parts.TITLEBAR_PART)),
sideBarSide: this._partService.getSideBarPosition() === Position.RIGHT ? 'right' : 'left',
editorPartMinWidth: DEFAULT_EDITOR_MIN_DIMENSIONS.width,
titleBarHeight: getTotalHeight(this._partService.getContainer(Parts.TITLEBAR_PART)),
activityBarWidth: getTotalWidth(this._partService.getContainer(Parts.ACTIVITYBAR_PART)),
sideBarWidth: getTotalWidth(this._partService.getContainer(Parts.SIDEBAR_PART)),
statusBarHeight: getTotalHeight(this._partService.getContainer(Parts.STATUSBAR_PART)),
Expand Down

0 comments on commit c412116

Please sign in to comment.