@@ -504,47 +504,56 @@ export class GitPanel extends React.Component<IGitPanelProps, IGitPanelState> {
504504 challengerCommit = { this . state . challengerCommit }
505505 onSelectForCompare = { commit => async event => {
506506 event . stopPropagation ( ) ;
507- this . setState ( { referenceCommit : commit } ) ;
507+ this . setState ( { referenceCommit : commit } , ( ) => {
508+ this . _openSingleFileComparison (
509+ event as React . MouseEvent < HTMLLIElement , MouseEvent >
510+ ) ;
511+ } ) ;
508512 } }
509513 onCompareWithSelected = { commit => async event => {
510514 event . stopPropagation ( ) ;
511- this . setState ( { challengerCommit : commit } ) ;
515+ this . setState ( { challengerCommit : commit } , ( ) => {
516+ this . _openSingleFileComparison (
517+ event as React . MouseEvent < HTMLLIElement , MouseEvent >
518+ ) ;
519+ } ) ;
512520 } }
513521 />
514- { ( this . state . referenceCommit || this . state . challengerCommit ) && (
515- < CommitComparisonBox
516- header = { this . props . trans . __ (
517- 'Compare %1 and %2' ,
518- this . state . referenceCommit
519- ? this . state . referenceCommit . commit . substring ( 0 , 7 )
520- : '...' ,
521- this . state . challengerCommit
522- ? this . state . challengerCommit . commit . substring ( 0 , 7 )
523- : '...'
524- ) }
525- referenceCommit = { this . state . referenceCommit }
526- challengerCommit = { this . state . challengerCommit }
527- commands = { this . props . commands }
528- model = { this . props . model }
529- logger = { this . props . logger }
530- trans = { this . props . trans }
531- onClose = { event => {
532- event . stopPropagation ( ) ;
533- this . setState ( {
534- referenceCommit : null ,
535- challengerCommit : null
536- } ) ;
537- } }
538- onOpenDiff = {
539- this . state . referenceCommit && this . state . challengerCommit
540- ? openFileDiff ( this . props . commands ) (
541- this . state . challengerCommit ,
542- this . state . referenceCommit
543- )
544- : undefined
545- }
546- />
547- ) }
522+ { this . props . model . selectedHistoryFile === null &&
523+ ( this . state . referenceCommit || this . state . challengerCommit ) && (
524+ < CommitComparisonBox
525+ header = { this . props . trans . __ (
526+ 'Compare %1 and %2' ,
527+ this . state . referenceCommit
528+ ? this . state . referenceCommit . commit . substring ( 0 , 7 )
529+ : '...' ,
530+ this . state . challengerCommit
531+ ? this . state . challengerCommit . commit . substring ( 0 , 7 )
532+ : '...'
533+ ) }
534+ referenceCommit = { this . state . referenceCommit }
535+ challengerCommit = { this . state . challengerCommit }
536+ commands = { this . props . commands }
537+ model = { this . props . model }
538+ logger = { this . props . logger }
539+ trans = { this . props . trans }
540+ onClose = { event => {
541+ event . stopPropagation ( ) ;
542+ this . setState ( {
543+ referenceCommit : null ,
544+ challengerCommit : null
545+ } ) ;
546+ } }
547+ onOpenDiff = {
548+ this . state . referenceCommit && this . state . challengerCommit
549+ ? openFileDiff ( this . props . commands ) (
550+ this . state . challengerCommit ,
551+ this . state . referenceCommit
552+ )
553+ : undefined
554+ }
555+ />
556+ ) }
548557 </ React . Fragment >
549558 ) ;
550559 }
@@ -851,4 +860,25 @@ export class GitPanel extends React.Component<IGitPanelProps, IGitPanelState> {
851860 }
852861 return < div > { elem } </ div > ;
853862 }
863+
864+ /**
865+ *
866+ */
867+ private _openSingleFileComparison (
868+ event : React . MouseEvent < HTMLLIElement , MouseEvent >
869+ ) : void {
870+ if (
871+ this . props . model . selectedHistoryFile &&
872+ this . state . referenceCommit &&
873+ this . state . challengerCommit
874+ ) {
875+ openFileDiff ( this . props . commands ) (
876+ this . state . challengerCommit ,
877+ this . state . referenceCommit
878+ ) (
879+ this . props . model . selectedHistoryFile . to ,
880+ ! this . props . model . selectedHistoryFile . is_binary
881+ ) ( event ) ;
882+ }
883+ }
854884}
0 commit comments