@@ -75,6 +75,9 @@ import { AriaLiveContainer } from '../accessibility/aria-live-container'
7575
7676const DefaultRowHeight = 20
7777
78+ let oldWidth = 0
79+ let oldHeight = 0
80+
7881export interface ISelection {
7982 /// Initial diff line number in the selection
8083 readonly from : number
@@ -623,43 +626,54 @@ export class SideBySideDiff extends React.Component<
623626 message = { ariaLiveMessage }
624627 trackedUserInput = { this . ariaLiveChangeSignal }
625628 />
626- < AutoSizer onResize = { this . clearListRowsHeightCache } >
627- { ( { height, width } ) => (
628- < List
629- deferredMeasurementCache = { listRowsHeightCache }
630- width = { width }
631- height = { height }
632- rowCount = { rows . length }
633- rowHeight = { this . getRowHeight }
634- rowRenderer = { this . renderRow }
635- onRowsRendered = { this . onRowsRendered }
636- ref = { this . virtualListRef }
637- overscanIndicesGetter = { this . overscanIndicesGetter }
638- // The following properties are passed to the list
639- // to make sure that it gets re-rendered when any of
640- // them change.
641- isSearching = { isSearching }
642- selectedSearchResult = { this . state . selectedSearchResult }
643- searchQuery = { this . state . searchQuery }
644- showSideBySideDiff = { this . props . showSideBySideDiff }
645- beforeTokens = { this . state . beforeTokens }
646- afterTokens = { this . state . afterTokens }
647- temporarySelection = { this . state . temporarySelection }
648- hoveredHunk = { this . state . hoveredHunk }
649- showDiffCheckMarks = { this . props . showDiffCheckMarks }
650- isSelectable = { canSelect ( this . props . file ) }
651- fileSelection = { this . getSelection ( ) }
652- // rows are memoized and include things like the
653- // noNewlineIndicator
654- rows = { rows }
655- />
656- ) }
629+ < AutoSizer >
630+ { ( { height, width } ) =>
631+ this . checkOnResize ( height , width ) && (
632+ < List
633+ deferredMeasurementCache = { listRowsHeightCache }
634+ width = { width }
635+ height = { height }
636+ rowCount = { rows . length }
637+ rowHeight = { this . getRowHeight }
638+ rowRenderer = { this . renderRow }
639+ onRowsRendered = { this . onRowsRendered }
640+ ref = { this . virtualListRef }
641+ overscanIndicesGetter = { this . overscanIndicesGetter }
642+ // The following properties are passed to the list
643+ // to make sure that it gets re-rendered when any of
644+ // them change.
645+ isSearching = { isSearching }
646+ selectedSearchResult = { this . state . selectedSearchResult }
647+ searchQuery = { this . state . searchQuery }
648+ showSideBySideDiff = { this . props . showSideBySideDiff }
649+ beforeTokens = { this . state . beforeTokens }
650+ afterTokens = { this . state . afterTokens }
651+ temporarySelection = { this . state . temporarySelection }
652+ hoveredHunk = { this . state . hoveredHunk }
653+ showDiffCheckMarks = { this . props . showDiffCheckMarks }
654+ isSelectable = { canSelect ( this . props . file ) }
655+ fileSelection = { this . getSelection ( ) }
656+ // rows are memoized and include things like the
657+ // noNewlineIndicator
658+ rows = { rows }
659+ />
660+ )
661+ }
657662 </ AutoSizer >
658663 </ div >
659664 </ div >
660665 )
661666 }
662667
668+ private checkOnResize = ( height : number , width : number ) => {
669+ if ( height !== oldHeight || width !== oldWidth ) {
670+ oldHeight = height
671+ oldWidth = width
672+ this . clearListRowsHeightCache ( )
673+ }
674+ return true
675+ }
676+
663677 private overscanIndicesGetter = ( params : OverscanIndicesGetterParams ) => {
664678 const [ start , end ] = [ this . textSelectionStartRow , this . textSelectionEndRow ]
665679
0 commit comments