Skip to content

skip unchanged padding in side-by-side git diffs - #19450

Merged
kevinushey merged 2 commits into
mainfrom
feature/19250-skip-unchanged-diff-padding
Nov 9, 2026
Merged

kevinushey merged 2 commits into
mainfrom
feature/19250-skip-unchanged-diff-padding

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Typing inside an already modified line in the side-by-side Git diff used to rebuild padding, reset both sessions' row caches, and request full redraws even when the layout stayed the same.

Compute the required padding using separate widget data and row caches, compare it with the applied layout, and update only panes whose padding changes. This retains the existing placement rules for soft wrap, folds, notebook output, and rows borrowed by the change action bar. Comparing screen-row padding rather than chunk ranges ensures wrapping changes are still handled.

Closes #19250.

Validation:

  • Standalone headless Chromium/Ace suite: 816 assertions passed across 10 pages, including 107 alignment assertions.
  • Baseline comparison: the original implementation fails 66 of the new assertions; the implementation passes all of them.
  • Real Ace renderer smoke check: 25 edits inside an already modified line produced 50 base-pane and 25 live-pane full-update requests on main, versus zero on both panes with this change. Following lines stayed aligned and no browser errors occurred.
  • JavaScript syntax and git diff --check passed; NEWS links to the verified issue.
  • Roborev Refine full-branch review passed with no findings; no LOW findings were ignored.
  • Full desktop E2E and manual UI testing were not run.

@kevinushey
kevinushey requested a review from gtritchie November 5, 2026 20:19
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

RStudio E2E - all platforms

1 test(s) failed

###################- 99% pass rate

Passed Failed Skipped Flaky
5249 1 260 3
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 4 0 16 0
✅ desktop-linux 1319 0 45 1
✅ desktop-macos 1326 0 40 0
❌ desktop-windows 1294 1 74 2
✅ server-linux 1258 0 53 0
✅ setup 48 0 32 0
View / download the full report

View report online -- opens in the browser, no download needed. Available for 14 days.

Download playwright-report.zip -- extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


All platforms - commit 6977f3440a42bc172cd009b24ae9e895236eb530 - Run #2114

@gtritchie gtritchie added this to the 2026.12 (Parrot Balsam) milestone Nov 5, 2026

@gtritchie gtritchie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. I didn't find any correctness issues in the planning and apply logic. Two small requests inline: the NEWS entry and a test assertion that can be skipped silently.

Optional, take or leave:

  • PaddingPlan.prototype.copyWidget repeats the padding-removal rules of $removeLineWidgets, which detach() still uses. They already differ slightly: copyWidget removes nested padding recursively, while $removeLineWidgets unwraps one level. A shared helper would keep them from drifting further.
  • PaddingPlan.prototype.apply calls session.$resetRowCache(0) and then emits changeFold from row 0, whose EditSession.onChangeFold handler resets the cache again. The old code had the same pairing, so this is a nit.
  • copySession relies on Ace's coordinate methods writing only to $docRowCache and $screenRowCache. That's true of the bundled Ace, but a one-line comment stating the assumption would help whoever next upgrades Ace.
  • A simpler alternative could be to re-pad in place without signalling, compare against a saved copy of lineWidgets and the peek's loan fields, and restore the saved state if they match. This is a design trade-off, not a defect.

Comment thread NEWS.md Outdated
## RStudio 2026.12.0 "Parrot Balsam" Release Notes

### New
- ([#19250](https://github.com/rstudio/rstudio/issues/19250)): The side-by-side Git diff view now avoids rebuilding alignment padding and redrawing both panes when an edit leaves the required padding unchanged.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The side-by-side view hasn't shipped yet: #19212 isn't in any release tag, and its user-facing entry is #19208. CLAUDE.md says not to add NEWS entries for fixes to unreleased features still under development, and the earlier follow-ups to this feature either amended the #19208 entry (#19350) or added none (#19225). Could this line be dropped? If the change should be mentioned, fold it into the #19208 entry instead.

Also, "avoids rebuilding alignment padding" isn't quite right: align() still computes the full padding plan on every realign, and what it skips is applying the plan and redrawing.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped in 6977f34. Agreed on both points: the view is unreleased, and the plan is still computed each realign; only the apply and redraw are skipped.

Comment on lines +214 to +219
try {
view.align();
} catch (error) {
check("failed planning leaves the applied layout intact", view.sessionA.lineWidgets === widgetsBefore &&
view.sessionA.$docRowCache === cacheBefore && peek.rowCount === 3 && peek.gitDiffLentRows === 2);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check only runs if align() throws. If a later change makes align() catch planning errors, the assertion never runs and the page still passes. Could you record a flag in the catch and check it alongside the layout afterwards? For example:

var threw = false;
try {
   view.align();
} catch (error) {
   threw = true;
}
check("failed planning throws", threw);
check("failed planning leaves the applied layout intact", ...);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 6977f34, with a separate "failed planning throws" assertion so a swallowed error fails the page too.

@kevinushey

Copy link
Copy Markdown
Collaborator Author

On the optional points:

  • Cache assumption: added a comment on copySession in 6977f34. In the bundled Ace the only in-place writes in the coordinate methods are the two cache pushes; anything else Ace assigns lands on the copy.
  • Shared helper: the while loop in $removeLineWidgets already strips padding at every depth of the chain, so the only one-level case is padding stacked on padding at the top, which $addWidget prevents by merging paddings on a row. Leaving as is since the two paths otherwise do different jobs (mutate vs copy).
  • Double reset: correct, EditSession.onChangeFold resets at row 0 too. Kept the explicit reset so apply matches $removeLineWidgets rather than relying on the handler; happy to drop both in a follow-up.
  • In-place alternative: planning on copies means a planning failure cannot leave the live widgets, caches or the peek's borrowed rows half-updated (the last test case covers that), and no changeFold has to be suppressed. So I kept the plan-then-compare approach.

@kevinushey
kevinushey merged commit e1d5e78 into main Nov 9, 2026
18 of 24 checks passed
@kevinushey
kevinushey deleted the feature/19250-skip-unchanged-diff-padding branch November 9, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Side-by-side Git diff: skip the realign when an update leaves the padding unchanged

2 participants