Skip to content

Conversation

@goran-w
Copy link
Contributor

@goran-w goran-w commented Dec 3, 2025

Both of the SingleSideTextDiffPresenter instances need to be scrolled/synced in AutoScrollToFirstChange(), for the auto-scrolling to work reliably. (To see where it failed, open a Side-By-Side Diff where the first change-block would be out-of-view, then toggle Show All Lines - when enabling the latter, the first change-block would NOT be correctly scrolled-to.)

As a bonus, a bit of cleanup and simplification was also done in related code:

  • Added private helper method GotoChange(), to remove redundant code.
  • Made SyncScrollOffset() virtual, so the Goto<...>Change() methods could be removed.
  • In DiffContext.CheckSettings(), setting the Context is now made on a single (less redundant) line, just like in the DiffContext.UseSideBySide setter.

Both of the SingleSideTextDiffPresenter instances need to be scrolled/synced for this to work reliably.

(To see where it failed, open a Side-By-Side Diff where the first change-block would be out-of-view, then toggle `Show All Lines` - when enabling the latter, the first change-block would NOT be correctly scrolled-to.)
* Added private helper method GotoChange(), to remove redundant code.
* Made `SyncScrollOffset()` virtual, so the `Goto<...>Change()` methods could be removed.
* In `DiffContext.CheckSettings()`, setting the Context is now made on a single (less redundant) line, just like in the `DiffContext.UseSideBySide` setter.
@goran-w goran-w force-pushed the fix_jump_to_first_change_in_two_sided_diff branch from 396f15b to ebc8d27 Compare December 3, 2025 22:00
@goran-w goran-w changed the title Fix: AutoScrollToFirstChange() was not working reliably for Side-By-Side Diff [BUG] Fix: AutoScrollToFirstChange() was not working reliably for Side-By-Side Diff Dec 3, 2025
@love-linger
Copy link
Collaborator

SyncScrollOffset() should not be called for Combined diff mode

love-linger added a commit that referenced this pull request Dec 4, 2025
@love-linger
Copy link
Collaborator

I've pushed my fix for this issue

@love-linger love-linger closed this Dec 4, 2025
love-linger added a commit that referenced this pull request Dec 4, 2025
@goran-w
Copy link
Contributor Author

goran-w commented Dec 4, 2025

I've pushed my fix for this issue

Great - looks good!

Seems like the SyncScrollOffset() method was no longer needed, at all...

A possible future improvement could be to jump to the current change-block (instead of back to the first one) when toggling Show All Lines and Side-By-Side Diff, since the set of changes are actually the same (only the visualization changes).

It's all about not losing context, when toggling these options - which I often do specifically to get another view of the very same change-block I'm looking at...

@goran-w goran-w deleted the fix_jump_to_first_change_in_two_sided_diff branch December 4, 2025 08:47
love-linger added a commit that referenced this pull request Dec 4, 2025
@goran-w
Copy link
Contributor Author

goran-w commented Dec 4, 2025

Excellent work on keeping the current change-block when toggling Show All Lines!

Could we also have this when toggling Side-By-Side Diff?

For that, it would probably be (more or less) sufficient to make the following changes :

  • Make the CombinedTextDiff and TwoSideTextDiff constructors take their previous arg as the base-class TextDiffContext (instead of as their own specific sub-classes).
  • Make the SwitchMode() methods pass the current (this) TextDiffContext as the previous arg to the constructor of the switched-to TextDiffContext sub-class.

love-linger added a commit that referenced this pull request Dec 4, 2025
@goran-w
Copy link
Contributor Author

goran-w commented Dec 4, 2025

Marvelous, current change-block is now kept also when toggling Side-By-Side Diff - thank you! 👍

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.

2 participants