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

diff viewer enhancements #136

Closed
grandinj opened this Issue Aug 23, 2012 · 9 comments

Comments

Projects
None yet
5 participants
@grandinj

grandinj commented Aug 23, 2012

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

This comment has been minimized.

Show comment
Hide comment
@grandinj

grandinj Aug 23, 2012

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

grandinj commented Aug 23, 2012

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

@davvid

This comment has been minimized.

Show comment
Hide comment
@davvid

davvid Aug 24, 2012

Member

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.

Member

davvid commented Aug 24, 2012

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 added a commit to davvid/git-cola that referenced this issue Sep 16, 2012

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>

davvid added a commit to davvid/git-cola that referenced this issue Sep 16, 2012

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>
@tverona

This comment has been minimized.

Show comment
Hide comment
@tverona

tverona Oct 2, 2012

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!

tverona commented Oct 2, 2012

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

This comment has been minimized.

Show comment
Hide comment
@Mailaender

Mailaender Oct 20, 2013

Contributor
  • 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!

Contributor

Mailaender commented Oct 20, 2013

  • 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

This comment has been minimized.

Show comment
Hide comment
@hrj

hrj Jul 21, 2014

+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 commented Jul 21, 2014

+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

This comment has been minimized.

Show comment
Hide comment
@hrj

hrj Apr 1, 2015

@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.

hrj commented Apr 1, 2015

@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

This comment has been minimized.

Show comment
Hide comment
@davvid

davvid Apr 14, 2015

Member

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.

Member

davvid commented Apr 14, 2015

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

This comment has been minimized.

Show comment
Hide comment
@hrj

hrj Apr 15, 2015

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 commented Apr 15, 2015

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

This comment has been minimized.

Show comment
Hide comment
@hrj

hrj Apr 15, 2015

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.

hrj commented Apr 15, 2015

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.

davvid added a commit that referenced this issue Jan 23, 2017

diff: reorder imports
Related-to: #136
Signed-off-by: David Aguilar <davvid@gmail.com>

davvid added a commit that referenced this issue Jan 23, 2017

diffparse: add docstrings
Related-to: #136
Signed-off-by: David Aguilar <davvid@gmail.com>

davvid added a commit that referenced this issue Jan 23, 2017

diffparse: rework tests to import the module
Related-to: #136
Signed-off-by: David Aguilar <davvid@gmail.com>

davvid added a commit that referenced this issue Jan 23, 2017

diffparse: add a diff line number parser
Related-to: #136
Signed-off-by: David Aguilar <davvid@gmail.com>

@davvid davvid closed this in 1cf8556 Jan 23, 2017

davvid added a commit that referenced this issue Jan 23, 2017

Merge branch 'diff-line-numbers'
Teach the diff editor to display line numbers.

* diff-line-numbers:
  diff: teach the diff editor to display line numbers
  diffparse: add a diff line number parser
  diffparse: rework tests to import the module
  diffparse: add docstrings
  grep: highlight the "current" line when browsing results
  diff: reorder imports

Closes #136
Signed-off-by: David Aguilar <davvid@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment