Delta: How to remove line number

Created on 15 Aug 2020  ยท  10Comments  ยท  Source: dandavison/delta

I just upgraded to v0.4 from v0.1 and the output now includes a number that looks very out of place.

(the one above "dependencies")
image

How can I get rid of it? I've tried many options but none of them helped.

Most helpful comment

perhaps the number can be kept if the line-numbers option is unset, shown if line-numbers = true, and hidden if line-numbers = false.

Yes, thanks, you're right, that was possible and that's in master. I'll release it early next week.

The slightly confusing thing is that --line-numbers is a boolean flag in the CLI, and hence doesn't allow this three-way logic. But you were right -- we can have the special semantics when it's used in git config, without too much hackiness in the code.

All 10 comments

Hi @chmln, thanks, that's fair I think. Short answer is:

  1. I think it's a bug that that number does not disappear when you use hunk-header-style = raw. I've just pushed a commit to the master branch that fixes that (so if you're able to build from source then you can have that fix now, otherwise I'll probably release a new version in the next few days.) When hunk-header-style = raw the line number is present in the hunk header, so it's not necessary to display it.

  2. You could use line-numbers if you're happy with full line numbers; that will get rid of the weird one solo number.

The solo number is the line number of the first line in the hunk (it is documented in the README). But you're right that there should be a way to opt out. As I said above, hunk-header-style = raw will now not show it, but perhaps there should also be a general opt-out option that permits non-raw hunk headers without any line number, and perhaps this ticket should be re-opened for that. Any thoughts?

@dandavison thanks for getting back, and your work on delta !

The screenshot is actually hunk-header-style = plain, is there a way to disable that number there as well ?

Hi!

The reason I was happy to get rid of the number for raw was that the number is actually displayed in the hunk-header under raw, e.g.

โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
@@ -476,7 +476,7 @@ fn handle_hunk_header_line( โ”‚
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

so it would be redundant to display 476 underneath as well.

However, by default Delta doesn't show all the @@ -476,7... stuff, as you know, and the default has long been to display that single line number underneath.

The semantics of normal (aka plain) are just that there should be no color, so there's no excuse really for messing with the line number: it would break orthogonality of the options, and Delta has quite a lot of options, so I'd like to keep their semantics as clear as possible.

So, what I'm thinking is that there would have to be a new option, with the semantics "never show the single line number".

I'm thinking that it It would be nice if this could be line-numbers = none. However, line-numbers is a boolean flag, so I don't _think_ I can convert it to a multi-valued option without breaking backwards compatibility (but perhaps/hopefully I'm missing a trick.)

By the way, there was a major change to delta after you first installed it. If you have a moment you might want to skim the release notes: v0.2.0.

A minor consequence of that release is that normal is now the documented way to request no color in a style string, with plain as a deprecated synonym. The justification for that is consistency with git's own style string language.

Appreciate the explanation @dandavison

The problem I now have with plain in v0.4 is that the line number looks like a part of code, which to me is completely jarring:

image

I'm using hunk-header-style = plain and hunk-header-decoration-style = plain.

If this can't be fixed I will just switch to raw, which despite the aesthetic downgrade is consistent :smile:

Right, the solitary line number inherits its color from the hunk-header-decoration-style. So we can do things like

[delta]
    light = true
    hunk-header-style = normal normal   # i.e. fg=normal bg=normal
    hunk-header-decoration-style = red ul    # or: red box
image

If you tell me the combination of colors/decorations you want, I'm happy to try to suggest the corresponding config settings.

I'm also happy to add an option to nuke that single line number in the next release; just mulling over the way to do it that is most harmonious with the existing CLI.

@dandavison perhaps the number can be kept if the line-numbers option is unset, shown if line-numbers = true, and hidden if line-numbers = false. But of course you might know a better way.

I don't think an option is worth it - I'm personally extremely averse to adding any non-critical options in my programs, opting for the most sensible behavior instead.

perhaps the number can be kept if the line-numbers option is unset, shown if line-numbers = true, and hidden if line-numbers = false.

Yes, thanks, you're right, that was possible and that's in master. I'll release it early next week.

The slightly confusing thing is that --line-numbers is a boolean flag in the CLI, and hence doesn't allow this three-way logic. But you were right -- we can have the special semantics when it's used in git config, without too much hackiness in the code.

Thanks for your work @dandavison fixing such a nitpick

Was this page helpful?
0 / 5 - 0 ratings