@@ -346,7 +346,7 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
346
346
key = { file . to }
347
347
actions = {
348
348
< React . Fragment >
349
- { this . _createDiffButton ( file , 'INDEX' ) }
349
+ { this . _maybeCreateDiffButton ( file , 'INDEX' ) }
350
350
< ActionButton
351
351
className = { hiddenButtonStyle }
352
352
iconName = { 'git-remove' }
@@ -410,7 +410,7 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
410
410
this . discardChanges ( file . to ) ;
411
411
} }
412
412
/>
413
- { this . _createDiffButton ( file , 'WORKING' ) }
413
+ { this . _maybeCreateDiffButton ( file , 'WORKING' ) }
414
414
< ActionButton
415
415
className = { hiddenButtonStyle }
416
416
iconName = { 'git-add' }
@@ -505,12 +505,12 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
505
505
this . discardChanges ( file . to ) ;
506
506
} }
507
507
/>
508
- { this . _createDiffButton ( file , 'WORKING' ) }
508
+ { this . _maybeCreateDiffButton ( file , 'WORKING' ) }
509
509
</ React . Fragment >
510
510
) ;
511
511
onDoubleClick = this . _onDoubleClickFactory ( file , 'WORKING' ) ;
512
512
} else if ( file . status === 'staged' ) {
513
- actions = this . _createDiffButton ( file , 'INDEX' ) ;
513
+ actions = this . _maybeCreateDiffButton ( file , 'INDEX' ) ;
514
514
onDoubleClick = this . _onDoubleClickFactory ( file , 'INDEX' ) ;
515
515
}
516
516
@@ -530,27 +530,47 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
530
530
}
531
531
532
532
/**
533
- * Creates a button element which is used to request diff of a file.
533
+ * Creates a button element which, depending on the settings, is used
534
+ * to either request a diff of the file, or open the file
534
535
*
535
536
* @param path File path of interest
536
537
* @param currentRef the ref to diff against the git 'HEAD' ref
537
538
*/
538
- private _createDiffButton (
539
+ private _maybeCreateDiffButton (
539
540
file : Git . IStatusFile ,
540
541
currentRef : ISpecialRef [ 'specialRef' ]
541
542
) : JSX . Element {
542
- return (
543
- ( isDiffSupported ( file . to ) || ! file . is_binary ) && (
543
+ if ( this . props . settings . composite [ 'doubleClickDiff' ] ) {
544
+ return (
544
545
< ActionButton
545
546
className = { hiddenButtonStyle }
546
- iconName = { 'git-diff' }
547
- title = { 'Diff this file' }
548
- onClick = { this . _openDiffViewFactory ( file , currentRef ) }
547
+ iconName = { 'open-file' }
548
+ title = { 'Open this file' }
549
+ onClick = { async ( ) => {
550
+ openListedFile ( file , this . props . model ) ;
551
+ } }
549
552
/>
550
- )
551
- ) ;
553
+ ) ;
554
+ } else {
555
+ return (
556
+ ( isDiffSupported ( file . to ) || ! file . is_binary ) && (
557
+ < ActionButton
558
+ className = { hiddenButtonStyle }
559
+ iconName = { 'git-diff' }
560
+ title = { 'Diff this file' }
561
+ onClick = { this . _openDiffViewFactory ( file , currentRef ) }
562
+ />
563
+ )
564
+ ) ;
565
+ }
552
566
}
553
567
568
+ /**
569
+ * Returns a callback which opens a diff of the file
570
+ *
571
+ * @param file
572
+ * @param currentRef the ref to diff against the git 'HEAD' ref
573
+ */
554
574
private _openDiffViewFactory (
555
575
file : Git . IStatusFile ,
556
576
currentRef : ISpecialRef [ 'specialRef' ]
@@ -576,6 +596,12 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
576
596
}
577
597
}
578
598
599
+ /**
600
+ * Returns a callback which is invoked upon double clicking a file
601
+ *
602
+ * @param file
603
+ * @param currentRef the ref to diff against the current git 'HEAD' ref
604
+ */
579
605
private _onDoubleClickFactory (
580
606
file : Git . IStatusFile ,
581
607
currentRef : ISpecialRef [ 'specialRef' ]
0 commit comments