Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sbatten committed Mar 12, 2019
1 parent 27a1eff commit 627e7e9
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/vs/editor/standalone/browser/simpleServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,5 +665,9 @@ export class SimpleLayoutService implements ILayoutService {
return this._container;
}

get hasWorkbench(): boolean {
return false;
}

constructor(private _container: HTMLElement) { }
}
13 changes: 8 additions & 5 deletions src/vs/platform/contextview/browser/contextMenuHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IContextMenuDelegate } from 'vs/base/browser/contextmenu';
import { addDisposableListener, EventType, $ } from 'vs/base/browser/dom';
import { addDisposableListener, EventType, $, removeNode } from 'vs/base/browser/dom';
import { attachMenuStyler } from 'vs/platform/theme/common/styler';
import { domEvent } from 'vs/base/browser/event';
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';

export class ContextMenuHandler {
private element: HTMLElement | null;
Expand All @@ -28,14 +29,14 @@ export class ContextMenuHandler {
private block: HTMLElement | null;

constructor(
element: HTMLElement | null,
private layoutService: ILayoutService,
private contextViewService: IContextViewService,
private telemetryService: ITelemetryService,
private notificationService: INotificationService,
private keybindingService: IKeybindingService,
private themeService: IThemeService
) {
this.setContainer(element);
this.setContainer(this.layoutService.container);
}

setContainer(container: HTMLElement | null): void {
Expand Down Expand Up @@ -75,7 +76,9 @@ export class ContextMenuHandler {
}

// Render invisible div to block mouse interaction in the rest of the UI
this.block = container.appendChild($('.context-view-block'));
if (this.layoutService.hasWorkbench) {
this.block = container.appendChild($('.context-view-block'));
}

const menuDisposables: IDisposable[] = [];

Expand Down Expand Up @@ -110,7 +113,7 @@ export class ContextMenuHandler {
}

if (this.block) {
this.block.remove();
removeNode(this.block);
this.block = null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/contextview/browser/contextMenuService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class ContextMenuService extends Disposable implements IContextMenuServic
) {
super();

this.contextMenuHandler = this._register(new ContextMenuHandler(layoutService.container, contextViewService, telemetryService, notificationService, keybindingService, themeService));
this.contextMenuHandler = this._register(new ContextMenuHandler(layoutService, contextViewService, telemetryService, notificationService, keybindingService, themeService));
}

dispose(): void {
Expand Down
6 changes: 6 additions & 0 deletions src/vs/platform/layout/browser/layoutService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@ export interface ILayoutService {
* event carries the dimensions of the container as part of it.
*/
readonly onLayout: Event<IDimension>;


/**
* Indicates if the layout has a workbench surrounding the editor
*/
readonly hasWorkbench: boolean;
}
2 changes: 2 additions & 0 deletions src/vs/workbench/browser/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {

get container(): HTMLElement { return this.workbench; }

get hasWorkbench(): boolean { return true; }

private parts: Map<string, Part> = new Map<string, Part>();

private workbenchGrid: Grid<View> | WorkbenchLegacyLayout;
Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/test/workbenchTestServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,10 @@ export class TestLayoutService implements IWorkbenchLayoutService {
return false;
}

public get hasWorkbench(): boolean {
return true;
}

public setEditorHidden(_hidden: boolean): Promise<void> { return Promise.resolve(); }

public setSideBarHidden(_hidden: boolean): Promise<void> { return Promise.resolve(); }
Expand Down

0 comments on commit 627e7e9

Please sign in to comment.