Skip to content

Commit

Permalink
Surface editor part size in event to avoid having to recompute it (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Nov 27, 2017
1 parent 952d76e commit 8f99fcd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
10 changes: 4 additions & 6 deletions src/vs/workbench/electron-browser/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'vs/css!./media/workbench';
import { localize } from 'vs/nls';
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';
Expand All @@ -37,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';
Expand Down Expand Up @@ -243,10 +243,8 @@ export class Workbench implements IPartService {
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;
}

/**
Expand Down
11 changes: 4 additions & 7 deletions src/vs/workbench/parts/watermark/electron-browser/watermark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { OpenRecentAction } from 'vs/workbench/electron-browser/actions';
import { GlobalNewUntitledFileAction } from 'vs/workbench/parts/files/electron-browser/fileActions';
import { OpenFolderAction, OpenFileFolderAction, OpenFileAction } from 'vs/workbench/browser/actions/workspaceActions';
import { ShowAllCommandsAction } from 'vs/workbench/parts/quickopen/browser/commandsHandler';
import { Parts, IPartService } from 'vs/workbench/services/part/common/partService';
import { Parts, IPartService, Dimension } from 'vs/workbench/services/part/common/partService';
import { StartAction } from 'vs/workbench/parts/debug/browser/debugActions';
import { FindInFilesActionId } from 'vs/workbench/parts/search/common/constants';
import { ToggleTerminalAction } from 'vs/workbench/parts/terminal/electron-browser/terminalActions';
Expand Down Expand Up @@ -176,15 +176,12 @@ export class WatermarkContribution implements IWorkbenchContribution {
});
});
};
const layout = () => {
const { height } = container.getBoundingClientRect();
container.classList[height <= 478 ? 'add' : 'remove']('max-height-478px');
};
update();
this.watermark.build(container.firstElementChild as HTMLElement, 0);
layout();
this.toDispose.push(this.keybindingService.onDidUpdateKeybindings(update));
this.toDispose.push(this.partService.onEditorLayout(layout));
this.toDispose.push(this.partService.onEditorLayout(({ height }: Dimension) => {
container.classList[height <= 478 ? 'add' : 'remove']('max-height-478px');
}));
}

private destroy(): void {
Expand Down
7 changes: 6 additions & 1 deletion src/vs/workbench/services/part/common/partService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export interface ILayoutOptions {
source?: Parts;
}

export interface Dimension {
readonly width: number;
readonly height: number;
}

export const IPartService = createDecorator<IPartService>('partService');

export interface IPartService {
Expand All @@ -41,7 +46,7 @@ export interface IPartService {
/**
* Emits when the editor part's layout changes.
*/
onEditorLayout: Event<void>;
onEditorLayout: Event<Dimension>;

/**
* Asks the part service to layout all parts.
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/test/workbenchTestServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Severity from 'vs/base/common/severity';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IPartService, Parts, Position as PartPosition } from 'vs/workbench/services/part/common/partService';
import { IPartService, Parts, Position as PartPosition, Dimension } from 'vs/workbench/services/part/common/partService';
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { IEditorInput, IEditorOptions, Position, Direction, IEditor, IResourceInput } from 'vs/platform/editor/common/editor';
Expand Down Expand Up @@ -342,13 +342,13 @@ export class TestPartService implements IPartService {
public _serviceBrand: any;

private _onTitleBarVisibilityChange = new Emitter<void>();
private _onEditorLayout = new Emitter<void>();
private _onEditorLayout = new Emitter<Dimension>();

public get onTitleBarVisibilityChange(): Event<void> {
return this._onTitleBarVisibilityChange.event;
}

public get onEditorLayout(): Event<void> {
public get onEditorLayout(): Event<Dimension> {
return this._onEditorLayout.event;
}

Expand Down

0 comments on commit 8f99fcd

Please sign in to comment.