Skip to content

Wrapped diff rows sometimes retain oversized heights after maximizing the window #23034

Open

Description

@molnarriso

The problem

When reading a text diff in History, maximizing a small window sometimes leaves large blank gaps between lines. The text unwraps to fit the wider preview, but the rows retain the height they needed when the preview was narrow.

This is intermittent in the current, unfixed application: sometimes resizing works correctly, and sometimes it does not. Moving the divider between the changed-file list and the diff preview fixes the spacing. After that, restoring and maximizing the same diff can continue to work correctly. Selecting a different commit while the window is small can make the problem return on the next maximize.

Expected: row heights should adjust to the wrapped text whenever the preview changes size, without needing to move the divider.

This happens in the text diff viewer, not a rendered Markdown preview. No error message was reported.

Release version

3.6.7

Operating system

Windows 11 25H2

Steps to reproduce the behavior

The following sequence was observed before the fix. Not every maximize triggers the problem.

  1. Open History in a small window.
  2. Select a commit containing a text file with at least two long lines, such as NEXT.md. Make the preview narrow enough that the lines wrap several times.
  3. Maximize the window. When the bug occurs, the text unwraps but large vertical gaps remain between rows. Other maximize attempts can resize correctly.
  4. Move the divider between the changed-file list and the diff preview slightly. The row spacing becomes correct.
  5. Restore the small window, then maximize again. In the observed sequence, the spacing now adjusts correctly, even without the fix.
  6. Restore the small window and select a different commit containing long wrapped lines.
  7. Maximize again. In the observed sequence, the oversized row spacing returns.

Log files

No response

Screenshots

  1. Small initial window :
Image 2. Windows maximised, row heights fail to adjust Image 3. Divider moved manually, row heights adjusts correctly Image

Additional context

Observed in a local fork of GitHub Desktop. The investigated base commit is bebc062caa on development.

Investigation points to stale measurements in SideBySideDiff, which renders both unified and side-by-side diffs using react-virtualized's AutoSizer, List, and CellMeasurer. The resize callback clears CellMeasurerCache, but does not explicitly recompute the list's row heights and positions.

AutoSizer calls setState with the new dimensions before invoking onResize. Outside React event batching, this can render the wider diff while the narrow-width measurements are still cached. The subsequent cache clear does not trigger another render, leaving oversized rows visible. Another resize can remeasure using the now-empty cache, explaining the divider recovery and successful later resize cycles. Switching commits can populate the cache again at the narrow width, causing the next maximize to fail again.

A suggested fix calls this.virtualListRef.current?.recomputeRowHeights() after clearing the measurement cache.

Component tests reproduce both the failing and working sequences before the fix:

Controlled test sequence Before fix With suggested fix
First narrow-to-wide resize with cached wrapped heights Incorrect: 180px instead of 20px Correct
Divider adjustment followed by restore/maximize Correct Correct
Switch commits while narrow, then maximize Incorrect: 180px instead of 20px Correct

These tests mount the actual diff and virtual-list components in jsdom with deterministic layout measurements. They confirm the resize lifecycle and row offsets; they do not automate native Windows maximize controls or actual font wrapping. The table describes controlled sequences, not a claim that every maximize fails before the fix.

Activity

  1. desktop-triage commented on Oct 17, 2026

    @desktop-triage

    Classification: Bug
    Priority: P3

    This is a bug report with a clear reproduction scenario and a specific root-cause theory tied to the diff viewer's virtualization logic, though the trigger is intermittent and affects a visual/cosmetic aspect (row spacing) rather than core functionality, with a workaround (nudging the divider). I'm suggesting bug and priority-3.

    Initial hypothesis: The reporter's analysis is consistent with the code. SideBySideDiff wraps its react-virtualized List in an AutoSizer whose onResize callback only calls clearListRowsHeightCache (

    private clearListRowsHeightCache = () => {
    listRowsHeightCache.clearAll()
    }
    ), which clears the shared CellMeasurerCache (
    <AutoSizer onResize={this.clearListRowsHeightCache}>
    ) but never calls recomputeRowHeights() on the List ref afterward (a call to that API exists elsewhere in the file, at
    list.recomputeRowHeights(index)
    , but not from the resize path). Since AutoSizer updates its own dimension state before invoking onResize, the List can re-render at the new width using stale (narrow-width) cached row heights for rows not yet remeasured, producing oversized gaps until another cache-clearing event (e.g., moving the divider) forces remeasurement. This matches the reporter's "divider fixes it" and "switching commits while narrow repopulates the stale state" observations. I did not independently reproduce the native resize timing race in Electron; the reporter's jsdom-based component tests are the only confirmation presented so far.

    Duplicate Check: Searched for related issues on diff row-height/resize problems; found no existing open or closed issue describing this specific wrapped-row/resize/CellMeasurerCache interaction. No duplicates found.

    Suggested Next Steps: Ready for engineering review — the reporter has a plausible fix (recomputeRowHeights() after cache clear) and claims to have component tests reproducing both failing and fixed behavior, which would help verify a PR.

    Generated by Issue Triage (skills-driven) for #23034 · auto · 29.3 AIC · ⌖ 1.28 AIC · ⊞ 9K · ◷

  2. added
    bug
    priority-3
    on Oct 20, 2026
  3. Shriraj1901 commented on Oct 28, 2026

    @Shriraj1901

    Hi @williammartin , I'd like to investigate this issue. I'll reproduce the incorrect row heights during window resizing and trace how the diff viewer refreshes its measurement cache. I'll look into whether the list needs to recalculate row heights after the cache is cleared, and add regression tests for the resize behaviour. Could you please confirm whether this issue is available for an external contribution and assign it to me if appropriate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority-3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions