22// Use of this source code is governed by a BSD-style license that can be
33// found in the LICENSE file.
44
5+ import * as Common from '../../core/common/common.js' ;
56import * as Host from '../../core/host/host.js' ;
67import * as i18n from '../../core/i18n/i18n.js' ;
78import * as Platform from '../../core/platform/platform.js' ;
@@ -38,6 +39,7 @@ interface SingleDiffViewInput {
3839 diff : Diff . Diff . DiffArray ;
3940 copied : boolean ;
4041 onCopy : ( fileUrl : string , diff : Diff . Diff . DiffArray ) => void ;
42+ onFileNameClick : ( fileUrl : string ) => void ;
4143}
4244
4345export interface ViewInput {
@@ -47,15 +49,15 @@ export interface ViewInput {
4749type View = ( input : ViewInput , output : undefined , target : HTMLElement ) => void ;
4850
4951function renderSingleDiffView ( singleDiffViewInput : SingleDiffViewInput ) : Lit . TemplateResult {
50- const { fileName, fileUrl, mimeType, icon, diff, copied, onCopy} = singleDiffViewInput ;
52+ const { fileName, fileUrl, mimeType, icon, diff, copied, onCopy, onFileNameClick } = singleDiffViewInput ;
5153
5254 return html `
5355 < details open >
5456 < summary >
5557 < div class ="summary-left ">
5658 < devtools-icon class ="drop-down-icon " .name =${ 'arrow-drop-down' } > </ devtools-icon >
5759 ${ icon }
58- < span class ="file-name " > ${ fileName } </ span >
60+ < button class ="file-name-link " @click = ${ ( ) => onFileNameClick ( fileUrl ) } > ${ fileName } </ button >
5961 </ div >
6062 < div class ="summary-right ">
6163 ${ copied ? html `< span class ="copied "> ${ i18nString ( UIStrings . copied ) } </ span > ` : html `
@@ -125,6 +127,11 @@ export class CombinedDiffView extends UI.Widget.Widget {
125127 } , COPIED_TO_CLIPBOARD_TEXT_TIMEOUT_MS ) ;
126128 }
127129
130+ #onFileNameClick( fileUrl : string ) : void {
131+ const uiSourceCode = this . #modifiedUISourceCodes. find ( uiSourceCode => uiSourceCode . url ( ) === fileUrl ) ;
132+ void Common . Revealer . reveal ( uiSourceCode ) ;
133+ }
134+
128135 async #initializeModifiedUISourceCodes( ) : Promise < void > {
129136 if ( ! this . #workspaceDiff) {
130137 return ;
@@ -183,6 +190,7 @@ export class CombinedDiffView extends UI.Widget.Widget {
183190 icon : PanelUtils . PanelUtils . getIconForSourceFile ( uiSourceCode , { width : 18 , height : 18 } ) ,
184191 copied : this . #copiedFiles[ uiSourceCode . url ( ) ] ,
185192 onCopy : this . #onCopyDiff. bind ( this ) ,
193+ onFileNameClick : this . #onFileNameClick. bind ( this ) ,
186194 } ;
187195 } )
188196 . sort ( ( a , b ) => Platform . StringUtilities . compare ( a . fileName , b . fileName ) ) ;
0 commit comments