@@ -14,16 +14,16 @@ import { DisposableStore, IDisposable } from '../../../../base/common/lifecycle.
1414import { ThemeIcon } from '../../../../base/common/themables.js' ;
1515import { generateUuid } from '../../../../base/common/uuid.js' ;
1616import { SymbolKinds } from '../../../../editor/common/languages.js' ;
17- import { SCMStructuralDiffElement , SCMStructuralDiffNode , getSCMStructuralDiffAriaLabel , getSCMStructuralDiffChange , getSCMStructuralDiffChangeAnnotation , getSCMStructuralDiffLabel } from '../common/scmStructuralDiff.js' ;
18- import { ICodeEditor , isDiffEditor } from '../../../../editor/browser/editorBrowser.js' ;
19- import { IRange , Range } from '../../../../editor/common/core/range.js' ;
17+ import { SCMStructuralDiffElement , SCMStructuralDiffNode , getSCMStructuralDiffAriaLabel , getSCMStructuralDiffChange , getSCMStructuralDiffChangeAnnotation , getSCMStructuralDiffLabel , getSCMStructuralDiffTarget } from '../common/scmStructuralDiff.js' ;
18+ import { isDiffEditor } from '../../../../editor/browser/editorBrowser.js' ;
2019import { ScrollType } from '../../../../editor/common/editorCommon.js' ;
2120import { IEditorOptions , TextEditorSelectionSource } from '../../../../platform/editor/common/editor.js' ;
2221import { IHoverService } from '../../../../platform/hover/browser/hover.js' ;
2322import { localize } from '../../../../nls.js' ;
2423import { DEFAULT_EDITOR_ASSOCIATION } from '../../../common/editor.js' ;
2524import { IEditorService , SIDE_GROUP } from '../../../services/editor/common/editorService.js' ;
2625import '../../../../editor/contrib/symbolIcons/browser/symbolIcons.js' ;
26+ import './media/scmStructuralDiff.css' ;
2727
2828interface StructuralDiffTemplate extends IDisposable {
2929 readonly icon : HTMLElement ;
@@ -34,7 +34,7 @@ interface StructuralDiffTemplate extends IDisposable {
3434 readonly elementDisposables : DisposableStore ;
3535}
3636
37- export class SCMStructuralDiffRenderer implements ICompressibleTreeRenderer < SCMStructuralDiffElement , FuzzyScore , StructuralDiffTemplate > {
37+ export class SCMStructuralDiffRenderer implements ICompressibleTreeRenderer < SCMStructuralDiffElement < object > , FuzzyScore | void , StructuralDiffTemplate > {
3838 static readonly TEMPLATE_ID = 'scmStructuralDiff' ;
3939 readonly templateId = SCMStructuralDiffRenderer . TEMPLATE_ID ;
4040 private readonly hoverGroupId = generateUuid ( ) ;
@@ -56,7 +56,7 @@ export class SCMStructuralDiffRenderer implements ICompressibleTreeRenderer<SCMS
5656 return { icon, label, metadata, annotation, status, elementDisposables, dispose : ( ) => disposables . dispose ( ) } ;
5757 }
5858
59- renderElement ( node : ITreeNode < SCMStructuralDiffElement , FuzzyScore > , _index : number , template : StructuralDiffTemplate ) : void {
59+ renderElement ( node : ITreeNode < SCMStructuralDiffElement < object > , FuzzyScore | void > , _index : number , template : StructuralDiffTemplate ) : void {
6060 const element = node . element ;
6161 const item = element . type === 'structuralDiff' ? element . node . modifiedItem ?? element . node . originalItem : undefined ;
6262 const change = getSCMStructuralDiffChange ( element ) ;
@@ -67,7 +67,7 @@ export class SCMStructuralDiffRenderer implements ICompressibleTreeRenderer<SCMS
6767 template . icon . classList . toggle ( 'codicon-colored' , ! ! item ) ;
6868 template . label . setLabel ( getSCMStructuralDiffLabel ( element ) , item ?. detail , {
6969 title : getSCMStructuralDiffAriaLabel ( element ) ,
70- matches : createMatches ( node . filterData ) ,
70+ matches : createMatches ( node . filterData as FuzzyScore | undefined ) ,
7171 labelEscapeNewLines : true ,
7272 } ) ;
7373 template . annotation . textContent = annotation ?. label ?? '' ;
@@ -91,7 +91,7 @@ export class SCMStructuralDiffRenderer implements ICompressibleTreeRenderer<SCMS
9191 }
9292 }
9393
94- disposeElement ( _node : ITreeNode < SCMStructuralDiffElement , FuzzyScore > , _index : number , template : StructuralDiffTemplate ) : void {
94+ disposeElement ( _node : ITreeNode < SCMStructuralDiffElement < object > , FuzzyScore | void > , _index : number , template : StructuralDiffTemplate ) : void {
9595 template . elementDisposables . clear ( ) ;
9696 }
9797
@@ -117,20 +117,8 @@ export async function openSCMStructuralDiff(element: SCMStructuralDiffNode, opti
117117 if ( ! isDiffEditor ( control ) || ! isCurrent ( ) ) {
118118 return ;
119119 }
120- const { originalItem, modifiedItem } = element . node ;
121- let target : ICodeEditor ;
122- let range : IRange ;
123- if ( modifiedItem ) {
124- target = control . getModifiedEditor ( ) ;
125- range = modifiedItem . selectionRange ?? modifiedItem . range ;
126- } else if ( control . renderSideBySide || ! element . deletedAt ) {
127- target = control . getOriginalEditor ( ) ;
128- range = originalItem ! . selectionRange ?? originalItem ! . range ;
129- } else {
130- // An inline diff hides the original editor and shows deleted text where it was deleted from the modified document.
131- target = control . getModifiedEditor ( ) ;
132- range = Range . fromPositions ( element . deletedAt ) ;
133- }
120+ const { side, range } = getSCMStructuralDiffTarget ( element , control . renderSideBySide ) ;
121+ const target = side === 'original' ? control . getOriginalEditor ( ) : control . getModifiedEditor ( ) ;
134122 target . setSelection ( range , TextEditorSelectionSource . NAVIGATION ) ;
135123 target . revealRangeInCenterIfOutsideViewport ( range , ScrollType . Smooth ) ;
136124 if ( ! options . preserveFocus ) {
0 commit comments