@@ -362,6 +362,7 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
362
362
model = { this . props . model }
363
363
selected = { this . _isSelectedFile ( file ) }
364
364
selectFile = { this . updateSelectedFile }
365
+ onDoubleClick = { this . _onDoubleClickFactory ( file , 'WORKING' ) }
365
366
/>
366
367
) ;
367
368
} ) }
@@ -425,6 +426,7 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
425
426
model = { this . props . model }
426
427
selected = { this . _isSelectedFile ( file ) }
427
428
selectFile = { this . updateSelectedFile }
429
+ onDoubleClick = { this . _onDoubleClickFactory ( file , 'WORKING' ) }
428
430
/>
429
431
) ;
430
432
} ) }
@@ -491,6 +493,7 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
491
493
>
492
494
{ files . map ( ( file : Git . IStatusFile ) => {
493
495
let actions = null ;
496
+ let onDoubleClick = null ;
494
497
if ( file . status === 'unstaged' ) {
495
498
actions = (
496
499
< React . Fragment >
@@ -505,8 +508,10 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
505
508
{ this . _createDiffButton ( file , 'WORKING' ) }
506
509
</ React . Fragment >
507
510
) ;
511
+ onDoubleClick = this . _onDoubleClickFactory ( file , 'WORKING' ) ;
508
512
} else if ( file . status === 'staged' ) {
509
513
actions = this . _createDiffButton ( file , 'INDEX' ) ;
514
+ onDoubleClick = this . _onDoubleClickFactory ( file , 'INDEX' ) ;
510
515
}
511
516
512
517
return (
@@ -516,6 +521,7 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
516
521
file = { file }
517
522
markBox = { true }
518
523
model = { this . props . model }
524
+ onDoubleClick = { onDoubleClick }
519
525
/>
520
526
) ;
521
527
} ) }
@@ -539,29 +545,49 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
539
545
className = { hiddenButtonStyle }
540
546
iconName = { 'git-diff' }
541
547
title = { 'Diff this file' }
542
- onClick = { async ( ) => {
543
- try {
544
- await openDiffView (
545
- file . to ,
546
- this . props . model ,
547
- {
548
- previousRef : { gitRef : 'HEAD' } ,
549
- currentRef : { specialRef : currentRef }
550
- } ,
551
- this . props . renderMime ,
552
- ! file . is_binary
553
- ) ;
554
- } catch ( reason ) {
555
- console . error (
556
- `Fail to open diff view for ${ file . to } .\n${ reason } `
557
- ) ;
558
- }
559
- } }
548
+ onClick = { this . _openDiffViewFactory ( file , currentRef ) }
560
549
/>
561
550
)
562
551
) ;
563
552
}
564
553
554
+ private _openDiffViewFactory (
555
+ file : Git . IStatusFile ,
556
+ currentRef : ISpecialRef [ 'specialRef' ]
557
+ ) {
558
+ const self = this ;
559
+ return genDiff ;
560
+
561
+ async function genDiff ( ) {
562
+ try {
563
+ await openDiffView (
564
+ file . to ,
565
+ self . props . model ,
566
+ {
567
+ previousRef : { gitRef : 'HEAD' } ,
568
+ currentRef : { specialRef : currentRef }
569
+ } ,
570
+ self . props . renderMime ,
571
+ ! file . is_binary
572
+ ) ;
573
+ } catch ( reason ) {
574
+ console . error ( `Fail to open diff view for ${ file . to } .\n${ reason } ` ) ;
575
+ }
576
+ }
577
+ }
578
+
579
+ private _onDoubleClickFactory (
580
+ file : Git . IStatusFile ,
581
+ currentRef : ISpecialRef [ 'specialRef' ]
582
+ ) {
583
+ if (
584
+ this . props . settings . composite [ 'doubleClickDiff' ] &&
585
+ ( isDiffSupported ( file . to ) || ! file . is_binary )
586
+ ) {
587
+ return this . _openDiffViewFactory ( file , currentRef ) ;
588
+ }
589
+ }
590
+
565
591
private _contextMenuStaged : Menu ;
566
592
private _contextMenuUnstaged : Menu ;
567
593
private _contextMenuUntracked : Menu ;
0 commit comments