提交 37670732 编写于 作者: B Benjamin Pasero

debt - reduce usage of || undefined

上级 bba6ee1c
...@@ -285,7 +285,7 @@ export abstract class CompositePart<T extends Composite> extends Part { ...@@ -285,7 +285,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
if (this.activeComposite && this.activeComposite.getId() === compositeId) { if (this.activeComposite && this.activeComposite.getId() === compositeId) {
// Title // Title
this.updateTitle(this.activeComposite.getId(), this.activeComposite.getTitle() || undefined); this.updateTitle(this.activeComposite.getId(), this.activeComposite.getTitle());
// Actions // Actions
const actionsBinding = this.collectCompositeActions(this.activeComposite); const actionsBinding = this.collectCompositeActions(this.activeComposite);
......
...@@ -425,7 +425,7 @@ export class OpenToSideFromQuickOpenAction extends Action { ...@@ -425,7 +425,7 @@ export class OpenToSideFromQuickOpenAction extends Action {
const input = entry.getInput(); const input = entry.getInput();
if (input) { if (input) {
if (input instanceof EditorInput) { if (input instanceof EditorInput) {
return this.editorService.openEditor(input, entry.getOptions() || undefined, SIDE_GROUP); return this.editorService.openEditor(input, entry.getOptions(), SIDE_GROUP);
} }
const resourceInput = input as IResourceInput; const resourceInput = input as IResourceInput;
......
...@@ -659,7 +659,7 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution { ...@@ -659,7 +659,7 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution {
const textModel = editorWidget.getModel(); const textModel = editorWidget.getModel();
if (textModel) { if (textModel) {
const modeId = textModel.getLanguageIdentifier().language; const modeId = textModel.getLanguageIdentifier().language;
info = { mode: this.modeService.getLanguageName(modeId) || undefined }; info = { mode: withNullAsUndefined(this.modeService.getLanguageName(modeId)) };
} }
} }
...@@ -832,7 +832,7 @@ function isWritableCodeEditor(codeEditor: ICodeEditor | undefined): boolean { ...@@ -832,7 +832,7 @@ function isWritableCodeEditor(codeEditor: ICodeEditor | undefined): boolean {
} }
function isWritableBaseEditor(e: IBaseEditor): boolean { function isWritableBaseEditor(e: IBaseEditor): boolean {
return e && isWritableCodeEditor(getCodeEditor(e.getControl()) || undefined); return e && isWritableCodeEditor(withNullAsUndefined(getCodeEditor(e.getControl())));
} }
export class ShowLanguageExtensionsAction extends Action { export class ShowLanguageExtensionsAction extends Action {
...@@ -893,7 +893,7 @@ export class ChangeModeAction extends Action { ...@@ -893,7 +893,7 @@ export class ChangeModeAction extends Action {
let modeId: string | undefined; let modeId: string | undefined;
if (textModel) { if (textModel) {
modeId = textModel.getLanguageIdentifier().language; modeId = textModel.getLanguageIdentifier().language;
currentModeId = this.modeService.getLanguageName(modeId) || undefined; currentModeId = withNullAsUndefined(this.modeService.getLanguageName(modeId));
} }
// All languages are valid picks // All languages are valid picks
......
...@@ -265,7 +265,7 @@ export class NoTabsTitleControl extends TitleControl { ...@@ -265,7 +265,7 @@ export class NoTabsTitleControl extends TitleControl {
title = ''; // dont repeat what is already shown title = ''; // dont repeat what is already shown
} }
editorLabel.setResource({ name, description, resource: resource || undefined }, { title: typeof title === 'string' ? title : undefined, italic: !isEditorPinned, extraClasses: ['no-tabs', 'title-label'] }); editorLabel.setResource({ name, description, resource }, { title: typeof title === 'string' ? title : undefined, italic: !isEditorPinned, extraClasses: ['no-tabs', 'title-label'] });
if (isGroupActive) { if (isGroupActive) {
editorLabel.element.style.color = this.getColor(TAB_ACTIVE_FOREGROUND); editorLabel.element.style.color = this.getColor(TAB_ACTIVE_FOREGROUND);
} else { } else {
......
...@@ -42,7 +42,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle'; ...@@ -42,7 +42,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { UNTITLED_WORKSPACE_NAME } from 'vs/platform/workspaces/common/workspaces'; import { UNTITLED_WORKSPACE_NAME } from 'vs/platform/workspaces/common/workspaces';
import { withUndefinedAsNull } from 'vs/base/common/types'; import { withUndefinedAsNull, withNullAsUndefined } from 'vs/base/common/types';
// Commands // Commands
...@@ -138,12 +138,12 @@ async function doSaveAs( ...@@ -138,12 +138,12 @@ async function doSaveAs(
editorGroupService: IEditorGroupsService, editorGroupService: IEditorGroupsService,
environmentService: IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService
): Promise<boolean> { ): Promise<boolean> {
let viewStateOfSource: IEditorViewState | null = null; let viewStateOfSource: IEditorViewState | undefined = undefined;
const activeTextEditorWidget = getCodeEditor(editorService.activeTextEditorWidget); const activeTextEditorWidget = getCodeEditor(editorService.activeTextEditorWidget);
if (activeTextEditorWidget) { if (activeTextEditorWidget) {
const activeResource = toResource(editorService.activeEditor, { supportSideBySide: SideBySideEditor.MASTER }); const activeResource = toResource(editorService.activeEditor, { supportSideBySide: SideBySideEditor.MASTER });
if (activeResource && (fileService.canHandleResource(activeResource) || resource.scheme === Schemas.untitled) && isEqual(activeResource, resource)) { if (activeResource && (fileService.canHandleResource(activeResource) || resource.scheme === Schemas.untitled) && isEqual(activeResource, resource)) {
viewStateOfSource = activeTextEditorWidget.saveViewState(); viewStateOfSource = withNullAsUndefined(activeTextEditorWidget.saveViewState());
} }
} }
...@@ -174,7 +174,7 @@ async function doSaveAs( ...@@ -174,7 +174,7 @@ async function doSaveAs(
resource: target, resource: target,
options: { options: {
pinned: true, pinned: true,
viewState: viewStateOfSource || undefined viewState: viewStateOfSource
} }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册