Skip to content

Conversation

gerhardol
Copy link
Member

@gerhardol gerhardol commented Sep 20, 2024

Proposed changes

This PR is to simplify troubleshooting, not really something that normal users will have benefit from.

GE currently tries to apply coloring with the "GE color engine"
for all files that ends with .diff or .patch.
This PR expands on this heuristics by trying to present colors in
files where the Git color engine has stored the colors as ANSI
terminal sequence.

If a file to present seem to be a diff file get the file with escape
sequences and present with the ansi terminal colors if they exist.
For other diff files, use the GE color engine.

Include tests/app/UnitTests/GitUI.Tests/Editor/Diff/AnsiTerminalColors.diff
to view terminal colors.

Also include a file to present the presentation of ansi terminal
colors.

tests/app/UnitTests/GitUI.Tests/Editor/Diff/diff_added_moved.diff
tests/app/UnitTests/GitUI.Tests/Editor/Diff/diff_removed_moved.diff
will also be used in follow ups

Note that all sample diff files are not displayed as they would be if Git
displays them

  • tests/app/UnitTests/GitUI.Tests/Editor/Diff/SampleCombined.diff
    Not stored with colors
    The output is not changed

  • tests/app/UnitTests/GitUI.Tests/Editor/Diff/SampleCombined.diff
    Not stored that this is a combined diff, so line numbers are not detected.

  • tests/app/UnitTests/GitUI.Tests/Editor/Diff/SampleDifftastic.diff
    Not stored that this is a difftastic file, so the GE adjustments are not done.
    fix: presentation tweak of command cache commands
    command
    Easier to copy the commands when viewing/debugging cache.

Screenshots

Syntax highlighting is deactivated to not distract
After includes #11851/#11862

image image

image image

image image

image image

image image

Test methodology

Manual - for debugging

Merge strategy

I agree that the maintainer squash merge this PR (if the commit message is clear).
(Could be rebase merged too, but the first commit is very minor.)


✒️ I contribute this code under The Developer Certificate of Origin.

If a file to present seem to be a diff file get the file with escape
sequences and present with the ansi terminal colors if they exist.
For other diff files, use the GE color engine.

Also include a file to present the presentation of ansi terminal
colors.
Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

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

Much PR description for an easy-to-follow, small code change. :)


Added .diff files often confuse me: Their header makes me think it was a changed file instead of a new one.

diff --git a/diff2.txt b/diff2.txt
index 0732af53..78580cd3 100644
--- a/diff2.txt
+++ b/diff2.txt

We should display a header for all added files like:

+++ b/tests/app/UnitTests/GitUI.Tests/Editor/Diff/diff_removed_moved.diff

Beware of editing files with escape sequences using the internal editor.
It removes all escape sequences.

@gerhardol gerhardol merged commit 68dc60d into gitextensions:master Sep 25, 2024
3 of 4 checks passed
@gerhardol gerhardol deleted the feature/view-diff-blob branch September 25, 2024 20:06
@RussKie RussKie added this to the 5.1 milestone Nov 6, 2024
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.

3 participants