Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How to remove line number #292

Closed
chmln opened this issue Aug 14, 2020 · 10 comments · Fixed by #296
Closed

How to remove line number #292

chmln opened this issue Aug 14, 2020 · 10 comments · Fixed by #296

Comments

@chmln
Copy link

chmln commented Aug 14, 2020

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.

@dandavison
Copy link
Owner

dandavison commented Aug 14, 2020

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?

@chmln
Copy link
Author

chmln commented Aug 14, 2020

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

@dandavison
Copy link
Owner

dandavison commented Aug 14, 2020

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

@dandavison
Copy link
Owner

dandavison commented Aug 14, 2020

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.

@chmln
Copy link
Author

chmln commented Aug 14, 2020

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 😄

@dandavison
Copy link
Owner

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

@dandavison
Copy link
Owner

dandavison commented Aug 14, 2020

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 dandavison reopened this Aug 14, 2020
@chmln
Copy link
Author

chmln commented Aug 17, 2020

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

@dandavison
Copy link
Owner

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.

@chmln
Copy link
Author

chmln commented Aug 21, 2020

Thanks for your work @dandavison fixing such a nitpick

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants