66import { IJSONSchema } from '../../../../base/common/jsonSchema.js' ;
77import { KeyChord , KeyCode , KeyMod } from '../../../../base/common/keyCodes.js' ;
88import { Schemas , matchesScheme } from '../../../../base/common/network.js' ;
9- import { extname } from '../../../../base/common/resources.js' ;
9+ import { extname , isEqual } from '../../../../base/common/resources.js' ;
1010import { isNumber , isObject , isString , isUndefined } from '../../../../base/common/types.js' ;
1111import { URI , UriComponents } from '../../../../base/common/uri.js' ;
1212import { isDiffEditor } from '../../../../editor/browser/editorBrowser.js' ;
@@ -41,6 +41,8 @@ import { IUntitledTextEditorService } from '../../../services/untitled/common/un
4141import { DIFF_FOCUS_OTHER_SIDE , DIFF_FOCUS_PRIMARY_SIDE , DIFF_FOCUS_SECONDARY_SIDE , DIFF_OPEN_SIDE , registerDiffEditorCommands } from './diffEditorCommands.js' ;
4242import { IResolvedEditorCommandsContext , resolveCommandsContext } from './editorCommandsContext.js' ;
4343import { prepareMoveCopyEditors } from './editor.js' ;
44+ import { IRange } from '../../../../editor/common/core/range.js' ;
45+ import { IMultiDiffEditorOptions } from '../../../../editor/browser/widget/multiDiffEditor/multiDiffEditorWidgetImpl.js' ;
4446
4547export const CLOSE_SAVED_EDITORS_COMMAND_ID = 'workbench.action.closeUnmodifiedEditors' ;
4648export const CLOSE_EDITORS_IN_GROUP_COMMAND_ID = 'workbench.action.closeEditorsInGroup' ;
@@ -551,10 +553,32 @@ function registerOpenEditorAPICommands(): void {
551553
552554 CommandsRegistry . registerCommand ( '_workbench.openMultiDiffEditor' , async ( accessor : ServicesAccessor , options : OpenMultiFileDiffEditorOptions ) => {
553555 const editorService = accessor . get ( IEditorService ) ;
556+
557+ const resources = options . resources ?. map ( r => ( { original : { resource : URI . revive ( r . originalUri ) } , modified : { resource : URI . revive ( r . modifiedUri ) } } ) ) ;
558+
559+ const revealUri = options . reveal ?. modifiedUri ? URI . revive ( options . reveal . modifiedUri ) : undefined ;
560+ const revealResource = revealUri && resources ? resources . find ( r => isEqual ( r . modified . resource , revealUri ) ) : undefined ;
561+ if ( options . reveal && ! revealResource ) {
562+ console . error ( 'Reveal resource not found' ) ;
563+ }
564+
565+ const multiDiffEditorOptions : IMultiDiffEditorOptions = {
566+ viewState : revealResource ? {
567+ revealData : {
568+ resource : {
569+ original : revealResource . original . resource ,
570+ modified : revealResource . modified . resource ,
571+ } ,
572+ range : options . reveal ?. range ,
573+ }
574+ } : undefined
575+ } ;
576+
554577 await editorService . openEditor ( {
555578 multiDiffSource : options . multiDiffSourceUri ? URI . revive ( options . multiDiffSourceUri ) : undefined ,
556- resources : options . resources ?. map ( r => ( { original : { resource : URI . revive ( r . originalUri ) } , modified : { resource : URI . revive ( r . modifiedUri ) } } ) ) ,
579+ resources,
557580 label : options . title ,
581+ options : multiDiffEditorOptions ,
558582 } ) ;
559583 } ) ;
560584}
@@ -563,6 +587,10 @@ interface OpenMultiFileDiffEditorOptions {
563587 title : string ;
564588 multiDiffSourceUri ?: UriComponents ;
565589 resources ?: { originalUri : UriComponents ; modifiedUri : UriComponents } [ ] ;
590+ reveal ?: {
591+ modifiedUri : UriComponents ;
592+ range ?: IRange ;
593+ } ;
566594}
567595
568596function registerOpenEditorAtIndexCommands ( ) : void {
0 commit comments