提交 6ae33840 编写于 作者: M Matt Bierner

getEditor() return null instead of undefined

上级 afe2da7e
......@@ -443,11 +443,11 @@ export function splitEditor(editorGroupService: IEditorGroupsService, direction:
const newGroup = editorGroupService.addGroup(sourceGroup, direction);
// Split editor (if it can be split)
let editorToCopy: IEditorInput | null;
let editorToCopy: IEditorInput | undefined;
if (context && typeof context.editorIndex === 'number') {
editorToCopy = sourceGroup.getEditor(context.editorIndex);
} else {
editorToCopy = sourceGroup.activeEditor;
editorToCopy = types.withNullAsUndefined(sourceGroup.activeEditor);
}
if (editorToCopy && (editorToCopy as EditorInput).supportsSplitEditor()) {
......
......@@ -729,7 +729,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
return this.editors;
}
getEditor(index: number): EditorInput | null {
getEditor(index: number): EditorInput | undefined {
return this._group.getEditor(index);
}
......
......@@ -695,7 +695,7 @@ export class TabsTitleControl extends TitleControl {
private updateDropFeedback(element: HTMLElement, isDND: boolean, index?: number): void {
const isTab = (typeof index === 'number');
const editor = typeof index === 'number' ? this.group.getEditor(index) : null;
const editor = typeof index === 'number' ? this.group.getEditor(index) : undefined;
const isActiveTab = isTab && !!editor && this.group.isActive(editor);
// Background
......
......@@ -138,16 +138,16 @@ export class EditorGroup extends Disposable {
return mru ? this.mru.slice(0) : this.editors.slice(0);
}
getEditor(index: number): EditorInput | null;
getEditor(resource: URI): EditorInput | null;
getEditor(arg1: number | URI): EditorInput | null {
getEditor(index: number): EditorInput | undefined;
getEditor(resource: URI): EditorInput | undefined;
getEditor(arg1: number | URI): EditorInput | undefined {
if (typeof arg1 === 'number') {
return this.editors[arg1];
}
const resource: URI = arg1;
if (!this.contains(resource)) {
return null; // fast check for resource opened or not
return undefined; // fast check for resource opened or not
}
for (const editor of this.editors) {
......@@ -157,7 +157,7 @@ export class EditorGroup extends Disposable {
}
}
return null;
return undefined;
}
get activeEditor(): EditorInput | null {
......
......@@ -411,7 +411,7 @@ export interface IEditorGroup {
/**
* Returns the editor at a specific index of the group.
*/
getEditor(index: number): IEditorInput | null;
getEditor(index: number): IEditorInput | undefined;
/**
* Get all editors that are currently opened in the group optionally
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册