-
Notifications
You must be signed in to change notification settings - Fork 618
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
Add support for hiding diff signs (leading + and -) #901
base: master
Are you sure you want to change the base?
Conversation
dd53e99
to
fc33964
Compare
I have now added the additional option |
fc33964
to
bfc4d78
Compare
I would suggest to rename the option from |
1701fe7
to
053eb5c
Compare
I did some testing and I like it a lot. But I have a question: Indeed you don't show the One of the arguments for this feature in #855 is to make copy-paste easier, but with the extra space you still need to remove that extra space. So there is not much difference between removing a leading With |
Good point! I would argue that removing extra spaces is in general easier than removing + and - signs (auto-indenting should mostly do the trick), but I do get your point. One suggestion is to only add the spaces when actually needing it: on empty lines when highlighted, or all if highlighted. I will attempt to provide such a version to try that out in a few hours. |
053eb5c
to
6b364bb
Compare
@ffes There is now a new version to try out that only adds the needed whitespace :) |
The `+` and `-` signs in diff views can be removed by changing the new option `diff-show-signs`. When set, only the color of the lines distinguishes added, removed and context lines. Closes jonas#855
Looks much better in When I look at this screenshot, I think with So I changed it to this: if (opt_diff_column_highlight == DIFF_COLUMN_HIGHLIGHT_ALL) {
if (type == LINE_DIFF_ADD) {
set_view_attr(view, LINE_DIFF_ADD_HIGHLIGHT);
} else if (type == LINE_DIFF_DEL) {
set_view_attr(view, LINE_DIFF_DEL_HIGHLIGHT);
}
waddch(view->win, ' ');
set_view_attr(view, type);
}
else if (opt_diff_column_highlight == DIFF_COLUMN_HIGHLIGHT_ONLY_EMPTY && len == 1) {
if (type == LINE_DIFF_ADD) {
set_view_attr(view, LINE_DIFF_ADD_HIGHLIGHT);
waddch(view->win, ' ');
} else if (type == LINE_DIFF_DEL) {
set_view_attr(view, LINE_DIFF_DEL_HIGHLIGHT);
waddch(view->win, ' ');
}
set_view_attr(view, type);
} |
The new option `diff-column-highlight` can be set to highlight all changed lines, only empty added/removed lines, or to not highlight in any special way. This option is only in effect when `diff-show-signs` is turned off. Default is to only highlight empty lines.
6b364bb
to
06e0edc
Compare
Oh, good catch! I took the liberty to include your code in the patch. I also figured out how to make the tests fail on whitespace-errors, and added test so that all three cases are now covered. |
That's why I included it 👍 Now let's hope @jonas likes and merges this 😉 |
if (view_has_flags(view, VIEW_DIFF_LIKE) && | ||
!opt_diff_show_signs && | ||
view->col == 0 && | ||
(type == LINE_DIFF_ADD || type == LINE_DIFF_DEL || type == LINE_DEFAULT) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LINE_DEFAULT is also used for the commit description so it is impacted as well.
You also miss the case of merge commits where diff --cc is used. In this case there are two columns of +- (try tig show f7b4319
in tig repository). Unfortunately draw_chars is too low level to know about it.
A while ago I gave it a try but didn't like it so it stayed in the box. If you want to have a look, I pushed it at https://github.com/koutcher/tig/tree/gh-855-hide-diff-signs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pointers!
In the repos I use at work there are no merge commits so I have completely missed that case :(
I will have a look at your branch and make a decision if this patch can be further developed or not.
The
+
and-
signs in diff views can be removed by changing the newoption
diff-show-signs
. When set, only the color of the linesdistinguishes added, removed and context lines.
The (also new) option
diff-column-highlight
tweaks how changed linesare visualized when the diff signs are suppressed. All changed lines can
be highlighted, only empty lines, or not to highlight in any special way
(except for the coloring of the added/removed text).
Closes #855