Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

diff viewer enhancements #136

Open
grandinj opened this Issue · 9 comments

5 participants

@grandinj

Awesome tool - the best Git GUI I've found, and I think I tried most of them today!

It would be nice (for me) if the "Diff Viewer"

(*) displayed line numbers on the left (like gedit for example)

(*) had a context menu entry that did "Launch Editor", since that's where my mouse normally is when I want to do such a thing

(*) Had up/down arrows for next-hunk/previous hunk

(*) had a tool-tip for the little "detach window" icon - I did not know what it was for initially

Thanks

@grandinj

Would also be nice the CTRL-E shortcut to open the editor worked when in the diff text panel.

@davvid
Owner

I also want the Ctrl-E shortcut to work in the diff panel. These are all very nice suggestions. The actions for launching the editor are low-hanging fruits and easier to do. I'll roll as many of these as possible into the next release.

@davvid davvid referenced this issue from a commit in davvid/git-cola
@davvid davvid widgets.diff: Add editor and difftool shortcuts
Add Ctrl+E (launch editor) and Ctrl+D (launch difftool)
shortcuts to the diff panel.

Suggested-by: @grandinj via github.com in #136
Signed-off-by: David Aguilar <davvid@gmail.com>
945b49c
@davvid davvid referenced this issue from a commit in davvid/git-cola
@davvid davvid main.view: Add tooltips to the detach and close buttons
Make the interface more discoverable by adding tooltips.

Suggested-by: @grandinj via github.com in #136
Signed-off-by: David Aguilar <davvid@gmail.com>
5d93b1a
@tverona

Agreed, awesome tool! One additional feature request regarding diffs: It would be great if it would recognize renamed files and diff them automatically (rather than showing them separately as added / deleted). Thank you!

@Mailaender
  • Highlight the actual changes in the lines (as github.com does it).

and I can agree with everyone here: awesome project, thank you very much!

@hrj

+1 for the comment by @Mailaender

I assume what they mean is:
Highlight the exact characters that have changed in the lines, apart from highlighting the changed lines too.

@hrj
hrj commented

@davvid If I were to implement character diffs in git-cola, what would it entail? Is it possible to do this by only changing the rendering? Would a simple algorithm like this work:

  • For every hunk that has line deletions followed by line additions:
    • Try to match the deleted line with an added line (based on ratio of changed characters to total number of charactes). If the ratio of changed characters is less than 0.5 than switch to character diff mode for that line, and keep a reference to the associated line.
    • For every line that is in character diff mode, highlight the change in characters by comparing with the associated line.
@davvid
Owner

It would probably be a little more involved than changing the rendering. It'd be awesome if it could be done.

Currently the diff viewer works by simply showing raw text and then using a QSyntaxHighlighter to highlight the add/remove lines. The "rendering" widget does very little, and we still deal with the raw output.

It might be tricky to implement, but I'd be happy if it were possible.

One complication would be going from the selection to the underlying diff; maybe there's a way to get a mapping. Another complication would be to interpret the raw git diff --word-diff output into something that looks nice, mutating it so that it can be displayed, and then being able to map between the mutated text and the real diff.

I would imagine that you'd want to use git diff --word-diff directly rather than trying to reimplement the algorithm. Another complication is ensuring that the tool only selects real diffs and doesn't hit any false positives when the content contains literal {+ ... +} and [- .... -] markers.

@hrj

Oh, the Syntax Highligther seems very easy to hack! I am looking at this code

It is currently processing the diff text one line at a time, but if it were to be modified to process one hunk at a time, this should be very easy.

Perhaps I am missing finer details that are visible to you. I will give it a shot anyway and see if I can cook up something.

@hrj

Oh, it just struck me. I have been playing around with string-similarity algorithms while querying querying records in a database. I could probably use a simple string-similarity algorithm (like Hamming distance) to match up the lines.

Using git diff --word-diff seems like a big change that is probably beyond me, as someone new to git-cola code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.