提交 110a59bb 编写于 作者: I isidor

Fix opening panel with focus:true no longer puts focus to editor within

fixes #59471
上级 b8de0589
......@@ -49,7 +49,7 @@ export interface ICompositeTitleLabel {
export abstract class CompositePart<T extends Composite> extends Part {
protected _onDidCompositeOpen = this._register(new Emitter<IComposite>());
protected _onDidCompositeOpen = this._register(new Emitter<{ composite: IComposite, focus: boolean }>());
protected _onDidCompositeClose = this._register(new Emitter<IComposite>());
protected toolBar: ToolBar;
......@@ -159,7 +159,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
});
}).then(composite => {
if (composite) {
this._onDidCompositeOpen.fire(composite);
this._onDidCompositeOpen.fire({ composite, focus });
}
return composite;
......
......@@ -6,7 +6,7 @@
import 'vs/css!./media/panelpart';
import { TPromise } from 'vs/base/common/winjs.base';
import { IAction } from 'vs/base/common/actions';
import { Event } from 'vs/base/common/event';
import { Event, mapEvent } from 'vs/base/common/event';
import { Registry } from 'vs/platform/registry/common/platform';
import { ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar';
import { IPanel } from 'vs/workbench/common/panel';
......@@ -119,13 +119,13 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
}
private registerListeners(): void {
this._register(this.onDidPanelOpen(this._onDidPanelOpen, this));
this._register(this.onDidPanelOpen(({ panel }) => this._onDidPanelOpen(panel)));
this._register(this.onDidPanelClose(this._onDidPanelClose, this));
this._register(this.registry.onDidRegister(panelDescriptor => this.compositeBar.addComposite(panelDescriptor)));
// Activate panel action on opening of a panel
this._register(this.onDidPanelOpen(panel => {
this._register(this.onDidPanelOpen(({ panel }) => {
this.compositeBar.activateComposite(panel.getId());
this.layoutCompositeBar(); // Need to relayout composite bar since different panels have different action bar width
}));
......@@ -146,8 +146,8 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
}
}
get onDidPanelOpen(): Event<IPanel> {
return this._onDidCompositeOpen.event;
get onDidPanelOpen(): Event<{ panel: IPanel, focus: boolean }> {
return mapEvent(this._onDidCompositeOpen.event, compositeOpen => ({ panel: compositeOpen.composite, focus: compositeOpen.focus }));
}
get onDidPanelClose(): Event<IPanel> {
......
......@@ -21,7 +21,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { Event } from 'vs/base/common/event';
import { Event, mapEvent } from 'vs/base/common/event';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { contrastBorder } from 'vs/platform/theme/common/colorRegistry';
import { SIDE_BAR_TITLE_FOREGROUND, SIDE_BAR_BACKGROUND, SIDE_BAR_FOREGROUND, SIDE_BAR_BORDER } from 'vs/workbench/common/theme';
......@@ -67,7 +67,7 @@ export class SidebarPart extends CompositePart<Viewlet> {
}
get onDidViewletOpen(): Event<IViewlet> {
return this._onDidCompositeOpen.event as Event<IViewlet>;
return mapEvent(this._onDidCompositeOpen.event, compositeEvent => <IViewlet>compositeEvent.composite);
}
get onDidViewletClose(): Event<IViewlet> {
......
......@@ -690,7 +690,7 @@ export class ToggleReplAction extends TogglePanelAction {
}
private registerListeners(): void {
this.toDispose.push(this.panelService.onDidPanelOpen(panel => {
this.toDispose.push(this.panelService.onDidPanelOpen(({ panel }) => {
if (panel.getId() === REPL_ID) {
this.class = 'debug-action toggle-repl';
this.tooltip = ToggleReplAction.LABEL;
......
......@@ -461,7 +461,7 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
}
this._register(registry.onDidRegisterChannel(this.onDidRegisterChannel, this));
this._register(panelService.onDidPanelOpen(this.onDidPanelOpen, this));
this._register(panelService.onDidPanelOpen(({ panel, focus }) => this.onDidPanelOpen(panel, !focus), this));
this._register(panelService.onDidPanelClose(this.onDidPanelClose, this));
// Set active channel to first channel if not set
......@@ -519,16 +519,16 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
this.channels.set(channelId, channel);
if (this.activeChannelIdInStorage === channelId) {
this.activeChannel = channel;
this.onDidPanelOpen(this.panelService.getActivePanel())
this.onDidPanelOpen(this.panelService.getActivePanel(), true)
.then(() => this._onActiveOutputChannel.fire(channelId));
}
}
private onDidPanelOpen(panel: IPanel): Thenable<void> {
private onDidPanelOpen(panel: IPanel, preserveFocus: boolean): Thenable<void> {
if (panel && panel.getId() === OUTPUT_PANEL_ID) {
this._outputPanel = <OutputPanel>this.panelService.getActivePanel();
if (this.activeChannel) {
return this.doShowChannel(this.activeChannel, true);
return this.doShowChannel(this.activeChannel, preserveFocus);
}
}
return TPromise.as(null);
......
......@@ -19,7 +19,7 @@ export interface IPanelIdentifier {
export interface IPanelService {
_serviceBrand: ServiceIdentifier<any>;
onDidPanelOpen: Event<IPanel>;
onDidPanelOpen: Event<{ panel: IPanel, focus: boolean }>;
onDidPanelClose: Event<IPanel>;
......
......@@ -31,7 +31,7 @@ export abstract class ScopedService extends Disposable {
registerListeners(): void {
this._register(this.viewletService.onDidViewletOpen(viewlet => this.onScopeOpened(viewlet.getId())));
this._register(this.panelService.onDidPanelOpen(panel => this.onScopeOpened(panel.getId())));
this._register(this.panelService.onDidPanelOpen(({ panel }) => this.onScopeOpened(panel.getId())));
this._register(this.viewletService.onDidViewletClose(viewlet => this.onScopeClosed(viewlet.getId())));
this._register(this.panelService.onDidPanelClose(panel => this.onScopeClosed(panel.getId())));
......
......@@ -66,7 +66,7 @@ class TestViewletService implements IViewletService {
class TestPanelService implements IPanelService {
public _serviceBrand: any;
onDidPanelOpen = new Emitter<IPanel>().event;
onDidPanelOpen = new Emitter<{ panel: IPanel, focus: boolean }>().event;
onDidPanelClose = new Emitter<IPanel>().event;
public openPanel(id: string, focus?: boolean): TPromise {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册