Skip to content

Commit 110a59b

Browse files
committed
Fix opening panel with focus:true no longer puts focus to editor within
fixes microsoft#59471
1 parent b8de058 commit 110a59b

8 files changed

Lines changed: 18 additions & 18 deletions

File tree

src/vs/workbench/browser/parts/compositePart.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export interface ICompositeTitleLabel {
4949

5050
export abstract class CompositePart<T extends Composite> extends Part {
5151

52-
protected _onDidCompositeOpen = this._register(new Emitter<IComposite>());
52+
protected _onDidCompositeOpen = this._register(new Emitter<{ composite: IComposite, focus: boolean }>());
5353
protected _onDidCompositeClose = this._register(new Emitter<IComposite>());
5454

5555
protected toolBar: ToolBar;
@@ -159,7 +159,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
159159
});
160160
}).then(composite => {
161161
if (composite) {
162-
this._onDidCompositeOpen.fire(composite);
162+
this._onDidCompositeOpen.fire({ composite, focus });
163163
}
164164

165165
return composite;

src/vs/workbench/browser/parts/panel/panelPart.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import 'vs/css!./media/panelpart';
77
import { TPromise } from 'vs/base/common/winjs.base';
88
import { IAction } from 'vs/base/common/actions';
9-
import { Event } from 'vs/base/common/event';
9+
import { Event, mapEvent } from 'vs/base/common/event';
1010
import { Registry } from 'vs/platform/registry/common/platform';
1111
import { ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar';
1212
import { IPanel } from 'vs/workbench/common/panel';
@@ -119,13 +119,13 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
119119
}
120120

121121
private registerListeners(): void {
122-
this._register(this.onDidPanelOpen(this._onDidPanelOpen, this));
122+
this._register(this.onDidPanelOpen(({ panel }) => this._onDidPanelOpen(panel)));
123123
this._register(this.onDidPanelClose(this._onDidPanelClose, this));
124124

125125
this._register(this.registry.onDidRegister(panelDescriptor => this.compositeBar.addComposite(panelDescriptor)));
126126

127127
// Activate panel action on opening of a panel
128-
this._register(this.onDidPanelOpen(panel => {
128+
this._register(this.onDidPanelOpen(({ panel }) => {
129129
this.compositeBar.activateComposite(panel.getId());
130130
this.layoutCompositeBar(); // Need to relayout composite bar since different panels have different action bar width
131131
}));
@@ -146,8 +146,8 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
146146
}
147147
}
148148

149-
get onDidPanelOpen(): Event<IPanel> {
150-
return this._onDidCompositeOpen.event;
149+
get onDidPanelOpen(): Event<{ panel: IPanel, focus: boolean }> {
150+
return mapEvent(this._onDidCompositeOpen.event, compositeOpen => ({ panel: compositeOpen.composite, focus: compositeOpen.focus }));
151151
}
152152

153153
get onDidPanelClose(): Event<IPanel> {

src/vs/workbench/browser/parts/sidebar/sidebarPart.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
2121
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
2222
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
2323
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
24-
import { Event } from 'vs/base/common/event';
24+
import { Event, mapEvent } from 'vs/base/common/event';
2525
import { IThemeService } from 'vs/platform/theme/common/themeService';
2626
import { contrastBorder } from 'vs/platform/theme/common/colorRegistry';
2727
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> {
6767
}
6868

6969
get onDidViewletOpen(): Event<IViewlet> {
70-
return this._onDidCompositeOpen.event as Event<IViewlet>;
70+
return mapEvent(this._onDidCompositeOpen.event, compositeEvent => <IViewlet>compositeEvent.composite);
7171
}
7272

7373
get onDidViewletClose(): Event<IViewlet> {

src/vs/workbench/parts/debug/browser/debugActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ export class ToggleReplAction extends TogglePanelAction {
690690
}
691691

692692
private registerListeners(): void {
693-
this.toDispose.push(this.panelService.onDidPanelOpen(panel => {
693+
this.toDispose.push(this.panelService.onDidPanelOpen(({ panel }) => {
694694
if (panel.getId() === REPL_ID) {
695695
this.class = 'debug-action toggle-repl';
696696
this.tooltip = ToggleReplAction.LABEL;

src/vs/workbench/parts/output/electron-browser/outputServices.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
461461
}
462462
this._register(registry.onDidRegisterChannel(this.onDidRegisterChannel, this));
463463

464-
this._register(panelService.onDidPanelOpen(this.onDidPanelOpen, this));
464+
this._register(panelService.onDidPanelOpen(({ panel, focus }) => this.onDidPanelOpen(panel, !focus), this));
465465
this._register(panelService.onDidPanelClose(this.onDidPanelClose, this));
466466

467467
// Set active channel to first channel if not set
@@ -519,16 +519,16 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
519519
this.channels.set(channelId, channel);
520520
if (this.activeChannelIdInStorage === channelId) {
521521
this.activeChannel = channel;
522-
this.onDidPanelOpen(this.panelService.getActivePanel())
522+
this.onDidPanelOpen(this.panelService.getActivePanel(), true)
523523
.then(() => this._onActiveOutputChannel.fire(channelId));
524524
}
525525
}
526526

527-
private onDidPanelOpen(panel: IPanel): Thenable<void> {
527+
private onDidPanelOpen(panel: IPanel, preserveFocus: boolean): Thenable<void> {
528528
if (panel && panel.getId() === OUTPUT_PANEL_ID) {
529529
this._outputPanel = <OutputPanel>this.panelService.getActivePanel();
530530
if (this.activeChannel) {
531-
return this.doShowChannel(this.activeChannel, true);
531+
return this.doShowChannel(this.activeChannel, preserveFocus);
532532
}
533533
}
534534
return TPromise.as(null);

src/vs/workbench/services/panel/common/panelService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface IPanelIdentifier {
1919
export interface IPanelService {
2020
_serviceBrand: ServiceIdentifier<any>;
2121

22-
onDidPanelOpen: Event<IPanel>;
22+
onDidPanelOpen: Event<{ panel: IPanel, focus: boolean }>;
2323

2424
onDidPanelClose: Event<IPanel>;
2525

src/vs/workbench/services/progress/browser/progressService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export abstract class ScopedService extends Disposable {
3131

3232
registerListeners(): void {
3333
this._register(this.viewletService.onDidViewletOpen(viewlet => this.onScopeOpened(viewlet.getId())));
34-
this._register(this.panelService.onDidPanelOpen(panel => this.onScopeOpened(panel.getId())));
34+
this._register(this.panelService.onDidPanelOpen(({ panel }) => this.onScopeOpened(panel.getId())));
3535

3636
this._register(this.viewletService.onDidViewletClose(viewlet => this.onScopeClosed(viewlet.getId())));
3737
this._register(this.panelService.onDidPanelClose(panel => this.onScopeClosed(panel.getId())));
@@ -296,4 +296,4 @@ export class ProgressService implements IProgressService {
296296

297297
return promise.then(stop, stop);
298298
}
299-
}
299+
}

src/vs/workbench/services/progress/test/progressService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class TestViewletService implements IViewletService {
6666
class TestPanelService implements IPanelService {
6767
public _serviceBrand: any;
6868

69-
onDidPanelOpen = new Emitter<IPanel>().event;
69+
onDidPanelOpen = new Emitter<{ panel: IPanel, focus: boolean }>().event;
7070
onDidPanelClose = new Emitter<IPanel>().event;
7171

7272
public openPanel(id: string, focus?: boolean): TPromise {

0 commit comments

Comments
 (0)