@@ -30,6 +30,7 @@ export const VirtualizedDiffViewer: React.FC<VirtualizedDiffViewerProps> = ({
30
30
miniMapWidth,
31
31
inlineDiffOptions,
32
32
} ) => {
33
+ const outerRef = useRef < Node > ( null ) ;
33
34
const listRef = useRef < List > ( null ) ;
34
35
const [ scrollTop , setScrollTop ] = useState ( 0 ) ;
35
36
@@ -167,6 +168,33 @@ export const VirtualizedDiffViewer: React.FC<VirtualizedDiffViewerProps> = ({
167
168
onScroll : ( scrollTop : number ) => listRef . current ?. scrollTo ( scrollTop ) ,
168
169
} ;
169
170
171
+ // Observe DOM changes in the diff viewer and update cells with the "empty-equal-cell" class
172
+ // whenever new rows are rendered, ensuring virtualized/scroll-loaded cells are handled.
173
+ useEffect ( ( ) => {
174
+ const container = outerRef . current as HTMLElement | null ;
175
+ if ( ! container )
176
+ return ;
177
+
178
+ const observer = new MutationObserver ( ( ) => {
179
+ const tds = container ?. querySelectorAll < HTMLTableCellElement > (
180
+ ".json-diff-viewer td.line-equal" ,
181
+ ) ;
182
+
183
+ tds . forEach ( ( td , index ) => {
184
+ td . classList . remove ( "empty-equal-cell" ) ;
185
+
186
+ const spans = td . querySelectorAll ( "pre > span" ) ;
187
+ if ( index % 2 === 1 && spans . length === 1 && spans [ 0 ] . textContent ?. trim ( ) === "" ) {
188
+ td . classList . add ( "empty-equal-cell" ) ;
189
+ }
190
+ } ) ;
191
+ } ) ;
192
+
193
+ observer . observe ( container ! , { childList : true , subtree : true } ) ;
194
+
195
+ return ( ) => observer . disconnect ( ) ;
196
+ } , [ ] ) ;
197
+
170
198
return (
171
199
< div className = { `diff-viewer-container${ className ? ` ${ className } ` : "" } ` } >
172
200
{ /* Header & Search */ }
@@ -208,6 +236,7 @@ export const VirtualizedDiffViewer: React.FC<VirtualizedDiffViewerProps> = ({
208
236
{ /* List & Minimap */ }
209
237
< div style = { { display : "flex" , gap : "8px" , position : "relative" } } >
210
238
< List
239
+ outerRef = { outerRef }
211
240
ref = { listRef }
212
241
className = "virtual-json-diff-list-container"
213
242
height = { height }
0 commit comments