6
6
import { IJSONSchema } from '../../../../base/common/jsonSchema.js' ;
7
7
import { KeyChord , KeyCode , KeyMod } from '../../../../base/common/keyCodes.js' ;
8
8
import { Schemas , matchesScheme } from '../../../../base/common/network.js' ;
9
- import { extname } from '../../../../base/common/resources.js' ;
9
+ import { extname , isEqual } from '../../../../base/common/resources.js' ;
10
10
import { isNumber , isObject , isString , isUndefined } from '../../../../base/common/types.js' ;
11
11
import { URI , UriComponents } from '../../../../base/common/uri.js' ;
12
12
import { isDiffEditor } from '../../../../editor/browser/editorBrowser.js' ;
@@ -41,6 +41,8 @@ import { IUntitledTextEditorService } from '../../../services/untitled/common/un
41
41
import { DIFF_FOCUS_OTHER_SIDE , DIFF_FOCUS_PRIMARY_SIDE , DIFF_FOCUS_SECONDARY_SIDE , DIFF_OPEN_SIDE , registerDiffEditorCommands } from './diffEditorCommands.js' ;
42
42
import { IResolvedEditorCommandsContext , resolveCommandsContext } from './editorCommandsContext.js' ;
43
43
import { prepareMoveCopyEditors } from './editor.js' ;
44
+ import { IRange } from '../../../../editor/common/core/range.js' ;
45
+ import { IMultiDiffEditorOptions } from '../../../../editor/browser/widget/multiDiffEditor/multiDiffEditorWidgetImpl.js' ;
44
46
45
47
export const CLOSE_SAVED_EDITORS_COMMAND_ID = 'workbench.action.closeUnmodifiedEditors' ;
46
48
export const CLOSE_EDITORS_IN_GROUP_COMMAND_ID = 'workbench.action.closeEditorsInGroup' ;
@@ -551,10 +553,32 @@ function registerOpenEditorAPICommands(): void {
551
553
552
554
CommandsRegistry . registerCommand ( '_workbench.openMultiDiffEditor' , async ( accessor : ServicesAccessor , options : OpenMultiFileDiffEditorOptions ) => {
553
555
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
+
554
577
await editorService . openEditor ( {
555
578
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,
557
580
label : options . title ,
581
+ options : multiDiffEditorOptions ,
558
582
} ) ;
559
583
} ) ;
560
584
}
@@ -563,6 +587,10 @@ interface OpenMultiFileDiffEditorOptions {
563
587
title : string ;
564
588
multiDiffSourceUri ?: UriComponents ;
565
589
resources ?: { originalUri : UriComponents ; modifiedUri : UriComponents } [ ] ;
590
+ reveal ?: {
591
+ modifiedUri : UriComponents ;
592
+ range ?: IRange ;
593
+ } ;
566
594
}
567
595
568
596
function registerOpenEditorAtIndexCommands ( ) : void {
0 commit comments