Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: diff - toggle show all lines (#615) #652

Merged

Conversation

goran-w
Copy link
Contributor

@goran-w goran-w commented Nov 4, 2024

This addresses the issue (suggestion) #615 - Implemented new TextDiff feature "Show All Lines" (toggle)

Summary of changes:

  • Added new ToggleButton in DiffView toolbar. It's visible only for Text Diff and it disables the buttons Increase/Decrease Number of Visible Lines when toggled ON.
  • Added new icon, as StreamGeometry Icons.Lines.All with SVG path from text_line_spacing_regular at https://avaloniaui.github.io/icons.html.
  • Added new String Text.Diff.VisualLines.All for en_US locale (no translations added yet).
  • Added new Preference property UseFullTextDiff to store this toggle setting.
  • Added new method DiffContext.ToggleFullTextDiff() for changing the preference property and reloading the diff content.
  • Added StyledProperty UseFullTextDiffProperty in TextDiffView, with a DataTemplate binding to the corresponding preference property.
  • When changed, UseFullTextDiffProperty is handled identically as UseSideBySideDiffProperty (via new helper method RefreshContent() for unification with OnDataContextChanged()).
  • Implemented the new feature by overriding the unified (number of context lines) param for Commands.Diff() with a very high number (done in DiffContext.LoadDiffContent()).
  • NOTE: The number used (~1 billion) is supposed to be the highest one working on Mac, according to this forum comment: https://stackoverflow.com/questions/28727424/for-git-diff-is-there-a-uinfinity-option-to-show-the-whole-file#comment135202820_28846576
  • Renamed the property TextDiff.SyncScrollOffset to TextDiff.ScrollOffset, to distinguish it from the identically named property TwoSideTextDiff.SyncScrollOffset. These two properties are distinct from each other and are used in separate (though slightly related) ways - they are not really connected, which initially confused me when reading the code. The one in TwoSideTextDiff is mainly used to keep the scroll-pos of the two SingleSideTextDiffPresenter views in sync (aligned), while the one in TextDiff is used only to preserve/reset the scroll-pos in the single CombinedTextDiffPresenter view when (re)loading Diff Content (so not really syncing anything).

The property "SyncScrollOffset" in TextDiff is distinct from the one with the same name in TwoSideTextDiff. These two properties are used in separate (though slightly related) ways and are not really connected.

The one in TwoSideTextDiff is mainly used to keep the scroll-pos of the two SingleSideTextDiffPresenter views in sync (aligned), while the one in TextDiff is used only to preserve/reset the scroll-pos in the single CombinedTextDiffPresenter view when (re)loading Diff Content (so not really syncing anything).

To clarify this and to make the two properties more distinguishable, I renamed the one in TextDiff to simply "ScrollOffset".
New StreamGeometry "Icons.Lines.All" using SVG path from "text_line_spacing_regular" at https://avaloniaui.github.io/icons.html.
New String "Text.Diff.VisualLines.All" for en_US locale (no translations yet).
* Added new ToggleButton in DiffView toolbar, visible when IsTextDiff, disabling the buttons "Increase/Decrease Number of Visible Lines" when on.

* Added new Preference property "UseFullTextDiff".

* Added StyledProperty "UseFullTextDiffProperty" in TextDiffView, with a DataTemplate binding to the corresponding preference property.

* When changed, UseFullTextDiffProperty is handled identically as UseSideBySideDiffProperty (via new helper method RefreshContent(), for unification with OnDataContextChanged()).

* Added new method DiffContext.ToggleFullTextDiff() for changing the preference property and reloading the diff content.

* Implemented the new feature by overriding the "unified" (number of context lines) for Commands.Diff() with a very high number.

NOTE: The number used (~1 billion) is supposed to be the highest one working on Mac, according to this forum comment: https://stackoverflow.com/questions/28727424/for-git-diff-is-there-a-uinfinity-option-to-show-the-whole-file#comment135202820_28846576
@goran-w goran-w changed the title Diff show entire file (#615) Diff toggle show all lines (#615) Nov 4, 2024
@goran-w goran-w changed the title Diff toggle show all lines (#615) feature: diff - toggle show all lines (#615) Nov 4, 2024
@love-linger love-linger self-assigned this Nov 4, 2024
@love-linger love-linger added the enhancement New feature or request label Nov 4, 2024
@love-linger love-linger linked an issue Nov 4, 2024 that may be closed by this pull request
@love-linger love-linger merged commit 1a8acbf into sourcegit-scm:develop Nov 4, 2024
13 checks passed
love-linger added a commit that referenced this pull request Nov 4, 2024
* update localization for zh_CN and zh_TW
* change the icon for `Icons.Lines.All`
* reorder diff view toolbar buttons
* move private methods after protected

Signed-off-by: leo <longshuang@msn.cn>
@goran-w goran-w deleted the diff-show-entire-file-615 branch November 28, 2024 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add toggle "Show entire file" for built-in Diff viewer
2 participants