@@ -9,9 +9,11 @@ import {ImageDiffMode} from './ImageDiffModeSelector';
99import { filePairDisplayName } from './utils' ;
1010import { DiffOptionsControl } from './DiffOptions' ;
1111import { KeyboardShortcuts } from './codediff/KeyboardShortcuts' ;
12+ import { GitConfig } from './options' ;
1213
1314declare const pairs : FilePair [ ] ;
1415declare const initialIdx : number ;
16+ declare const GIT_CONFIG : GitConfig ;
1517
1618type Props = RouteComponentProps < { index ?: string } > ;
1719
@@ -20,6 +22,7 @@ export function Root(props: Props) {
2022 const [ pdiffMode , setPDiffMode ] = React . useState < PerceptualDiffMode > ( 'off' ) ;
2123 const [ imageDiffMode , setImageDiffMode ] = React . useState < ImageDiffMode > ( 'side-by-side' ) ;
2224 const [ diffOptions , setDiffOptions ] = React . useState < Partial < DiffOptions > > ( { } ) ;
25+ const [ maxDiffWidth , setMaxDiffWidth ] = React . useState ( GIT_CONFIG . webdiff . maxDiffWidth ) ;
2326 const [ showKeyboardHelp , setShowKeyboardHelp ] = React . useState ( false ) ;
2427 const [ showOptions , setShowOptions ] = React . useState ( false ) ;
2528 // An explicit list is better, unless there are a ton of files.
@@ -69,38 +72,49 @@ export function Root(props: Props) {
6972 } ;
7073 } , [ idx , selectIndex ] ) ;
7174
75+ const inlineStyle = `
76+ td.code {
77+ width: ${ 1 + maxDiffWidth } ch;
78+ }` ;
79+
7280 return (
73- < div >
74- < DiffOptionsControl
75- options = { diffOptions }
76- setOptions = { setDiffOptions }
77- isVisible = { showOptions }
78- setIsVisible = { setShowOptions }
79- />
80- < FileSelector
81- selectedFileIndex = { idx }
82- filePairs = { pairs }
83- fileChangeHandler = { selectIndex }
84- mode = { fileSelectorMode }
85- onChangeMode = { setFileSelectorMode }
86- />
87- { showKeyboardHelp ? (
88- < KeyboardShortcuts
89- onClose = { ( ) => {
90- setShowKeyboardHelp ( false ) ;
91- } }
81+ < >
82+ < style > { inlineStyle } </ style >
83+ < div >
84+ < DiffOptionsControl
85+ options = { diffOptions }
86+ setOptions = { setDiffOptions }
87+ maxDiffWidth = { maxDiffWidth }
88+ setMaxDiffWidth = { setMaxDiffWidth }
89+ defaultMaxDiffWidth = { GIT_CONFIG . webdiff . maxDiffWidth }
90+ isVisible = { showOptions }
91+ setIsVisible = { setShowOptions }
92+ />
93+ < FileSelector
94+ selectedFileIndex = { idx }
95+ filePairs = { pairs }
96+ fileChangeHandler = { selectIndex }
97+ mode = { fileSelectorMode }
98+ onChangeMode = { setFileSelectorMode }
99+ />
100+ { showKeyboardHelp ? (
101+ < KeyboardShortcuts
102+ onClose = { ( ) => {
103+ setShowKeyboardHelp ( false ) ;
104+ } }
105+ />
106+ ) : null }
107+ < DiffView
108+ key = { `diff-${ idx } ` }
109+ thinFilePair = { filePair }
110+ imageDiffMode = { imageDiffMode }
111+ pdiffMode = { pdiffMode }
112+ diffOptions = { diffOptions }
113+ changeImageDiffMode = { setImageDiffMode }
114+ changePDiffMode = { setPDiffMode }
115+ changeDiffOptions = { setDiffOptions }
92116 />
93- ) : null }
94- < DiffView
95- key = { `diff-${ idx } ` }
96- thinFilePair = { filePair }
97- imageDiffMode = { imageDiffMode }
98- pdiffMode = { pdiffMode }
99- diffOptions = { diffOptions }
100- changeImageDiffMode = { setImageDiffMode }
101- changePDiffMode = { setPDiffMode }
102- changeDiffOptions = { setDiffOptions }
103- />
104- </ div >
117+ </ div >
118+ </ >
105119 ) ;
106120}
0 commit comments