mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 03:54:24 +01:00
Converting some parts of panel service to return undefined instead of null
This commit is contained in:
@@ -61,7 +61,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
|
||||
private mapCompositeToCompositeContainer = new Map<string, HTMLElement>();
|
||||
private mapActionsBindingToComposite = new Map<string, () => void>();
|
||||
private activeComposite: Composite | null;
|
||||
private activeComposite: Composite | undefined;
|
||||
private lastActiveCompositeId: string;
|
||||
private instantiatedCompositeItems: Map<string, CompositeItem>;
|
||||
private titleLabel: ICompositeTitleLabel;
|
||||
@@ -90,7 +90,6 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
) {
|
||||
super(id, options, themeService, storageService, layoutService);
|
||||
|
||||
this.activeComposite = null;
|
||||
this.instantiatedCompositeItems = new Map<string, CompositeItem>();
|
||||
this.lastActiveCompositeId = storageService.get(activeCompositeSettingsKey, StorageScope.WORKSPACE, this.defaultCompositeId);
|
||||
}
|
||||
@@ -332,7 +331,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
return this.toolBar.setActions(prepareActions(primaryActions), prepareActions(secondaryActions));
|
||||
}
|
||||
|
||||
protected getActiveComposite(): IComposite | null {
|
||||
protected getActiveComposite(): IComposite | undefined {
|
||||
return this.activeComposite;
|
||||
}
|
||||
|
||||
@@ -346,7 +345,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
}
|
||||
|
||||
const composite = this.activeComposite;
|
||||
this.activeComposite = null;
|
||||
this.activeComposite = undefined;
|
||||
|
||||
const compositeContainer = this.mapCompositeToCompositeContainer.get(composite.getId());
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import { Dimension, trackFocus } from 'vs/base/browser/dom';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { isUndefinedOrNull, withUndefinedAsNull, assertIsDefined } from 'vs/base/common/types';
|
||||
import { isUndefinedOrNull, assertIsDefined } from 'vs/base/common/types';
|
||||
import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
|
||||
@@ -218,9 +218,9 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
|
||||
}
|
||||
}
|
||||
|
||||
openPanel(id: string, focus?: boolean): Panel | null {
|
||||
openPanel(id: string, focus?: boolean): Panel | undefined {
|
||||
if (this.blockOpeningPanel) {
|
||||
return null; // Workaround against a potential race condition
|
||||
return undefined; // Workaround against a potential race condition
|
||||
}
|
||||
|
||||
// First check if panel is hidden and show if so
|
||||
@@ -233,7 +233,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
|
||||
}
|
||||
}
|
||||
|
||||
return withUndefinedAsNull(this.openComposite(id, focus));
|
||||
return this.openComposite(id, focus);
|
||||
}
|
||||
|
||||
showActivity(panelId: string, badge: IBadge, clazz?: string): IDisposable {
|
||||
@@ -263,7 +263,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
|
||||
];
|
||||
}
|
||||
|
||||
getActivePanel(): IPanel | null {
|
||||
getActivePanel(): IPanel | undefined {
|
||||
return this.getActiveComposite();
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
|
||||
}
|
||||
}
|
||||
|
||||
private onDidPanelOpen(panel: IPanel | null, preserveFocus: boolean): Promise<void> {
|
||||
private onDidPanelOpen(panel: IPanel | undefined, preserveFocus: boolean): Promise<void> {
|
||||
if (panel && panel.getId() === OUTPUT_PANEL_ID) {
|
||||
this._outputPanel = <OutputPanel>this.panelService.getActivePanel();
|
||||
if (this.activeChannel) {
|
||||
|
||||
@@ -28,12 +28,12 @@ export interface IPanelService {
|
||||
/**
|
||||
* Opens a panel with the given identifier and pass keyboard focus to it if specified.
|
||||
*/
|
||||
openPanel(id: string, focus?: boolean): IPanel | null;
|
||||
openPanel(id: string, focus?: boolean): IPanel | undefined;
|
||||
|
||||
/**
|
||||
* Returns the current active panel or null if none
|
||||
*/
|
||||
getActivePanel(): IPanel | null;
|
||||
getActivePanel(): IPanel | undefined;
|
||||
|
||||
/**
|
||||
* Returns the panel by id.
|
||||
|
||||
@@ -79,7 +79,7 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
onDidPanelOpen = Event.None;
|
||||
onDidPanelClose = Event.None;
|
||||
getActivePanel() {
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
TestEnvironmentService
|
||||
|
||||
@@ -111,7 +111,7 @@ suite('MainThreadEditors', () => {
|
||||
onDidPanelOpen = Event.None;
|
||||
onDidPanelClose = Event.None;
|
||||
getActivePanel() {
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
TestEnvironmentService
|
||||
|
||||
@@ -626,8 +626,8 @@ export class TestPanelService implements IPanelService {
|
||||
onDidPanelOpen = new Emitter<{ panel: IPanel, focus: boolean }>().event;
|
||||
onDidPanelClose = new Emitter<IPanel>().event;
|
||||
|
||||
public openPanel(id: string, focus?: boolean): IPanel {
|
||||
return null!;
|
||||
public openPanel(id: string, focus?: boolean): undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public getPanel(id: string): any {
|
||||
|
||||
Reference in New Issue
Block a user