@@ -16,7 +16,7 @@ import { URI } from 'vs/base/common/uri';
1616import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen' ;
1717import { IListService } from 'vs/platform/list/browser/listService' ;
1818import { List } from 'vs/base/browser/ui/list/listWidget' ;
19- import { distinct } from 'vs/base/common/arrays' ;
19+ import { distinct , coalesce } from 'vs/base/common/arrays' ;
2020import { IEditorGroupsService , IEditorGroup , GroupDirection , GroupLocation , GroupsOrder , preferredSideBySideGroupDirection , EditorGroupLayout } from 'vs/workbench/services/editor/common/editorGroupsService' ;
2121import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey' ;
2222import { IConfigurationService , ConfigurationTarget } from 'vs/platform/configuration/common/configuration' ;
@@ -52,9 +52,9 @@ export const NAVIGATE_IN_ACTIVE_GROUP_PREFIX = 'edt active ';
5252export const OPEN_EDITOR_AT_INDEX_COMMAND_ID = 'workbench.action.openEditorAtIndex' ;
5353
5454export interface ActiveEditorMoveArguments {
55- to ? : 'first' | 'last' | 'left' | 'right' | 'up' | 'down' | 'center' | 'position' | 'previous' | 'next' ;
56- by ? : 'tab' | 'group' ;
57- value ? : number ;
55+ to : 'first' | 'last' | 'left' | 'right' | 'up' | 'down' | 'center' | 'position' | 'previous' | 'next' ;
56+ by : 'tab' | 'group' ;
57+ value : number ;
5858}
5959
6060const isActiveEditorMoveArg = function ( arg : ActiveEditorMoveArguments ) : boolean {
@@ -357,7 +357,7 @@ function registerOpenEditorAtIndexCommands(): void {
357357 case 9 : return KeyCode . KEY_9 ;
358358 }
359359
360- return undefined ;
360+ throw new Error ( 'invalid index' ) ;
361361 }
362362}
363363
@@ -409,7 +409,7 @@ function registerFocusEditorGroupAtIndexCommands(): void {
409409 case 7 : return 'workbench.action.focusEighthEditorGroup' ;
410410 }
411411
412- return undefined ;
412+ throw new Error ( 'Invalid index' ) ;
413413 }
414414
415415 function toKeyCode ( index : number ) : KeyCode {
@@ -423,7 +423,7 @@ function registerFocusEditorGroupAtIndexCommands(): void {
423423 case 7 : return KeyCode . KEY_8 ;
424424 }
425425
426- return undefined ;
426+ throw new Error ( 'Invalid index' ) ;
427427 }
428428}
429429
@@ -528,9 +528,9 @@ function registerCloseEditorCommands() {
528528
529529 return Promise . all ( groupIds . map ( groupId => {
530530 const group = editorGroupService . getGroup ( groupId ) ;
531- const editors = contexts
531+ const editors = coalesce ( contexts
532532 . filter ( context => context . groupId === groupId )
533- . map ( context => typeof context . editorIndex === 'number' ? group . getEditor ( context . editorIndex ) : group . activeEditor ) ;
533+ . map ( context => typeof context . editorIndex === 'number' ? group . getEditor ( context . editorIndex ) : group . activeEditor ) ) ;
534534
535535 return group . closeEditors ( editors ) ;
536536 } ) ) ;
@@ -675,7 +675,7 @@ function getCommandsContext(resourceOrContext: URI | IEditorCommandsContext, con
675675 return undefined ;
676676}
677677
678- function resolveCommandsContext ( editorGroupService : IEditorGroupsService , context ?: IEditorCommandsContext ) : { group : IEditorGroup , editor : IEditorInput , control : IEditor } {
678+ function resolveCommandsContext ( editorGroupService : IEditorGroupsService , context ?: IEditorCommandsContext ) : { group : IEditorGroup , editor ? : IEditorInput , control ? : IEditor } {
679679
680680 // Resolve from context
681681 let group = context && typeof context . groupId === 'number' ? editorGroupService . getGroup ( context . groupId ) : undefined ;
@@ -689,7 +689,7 @@ function resolveCommandsContext(editorGroupService: IEditorGroupsService, contex
689689 control = group . activeControl ;
690690 }
691691
692- return { group, editor, control } ;
692+ return { group, editor : editor || undefined , control : control || undefined } ;
693693}
694694
695695export function getMultiSelectedEditorContexts ( editorContext : IEditorCommandsContext | undefined , listService : IListService , editorGroupService : IEditorGroupsService ) : IEditorCommandsContext [ ] {
0 commit comments