Skip to content
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

Set margin size only when there are file changes in diff-hl-margin-mode #220

Open
haditim opened this issue Jun 23, 2024 · 2 comments
Open

Comments

@haditim
Copy link

haditim commented Jun 23, 2024

Hello and thanks a lot for the awesome package.

I hope this is not a question that has been answered before, I searched everything related to diff-hl-margin-mode and could not find answer to this. The question is whether there is a way to utilize the margin (i.e. set its value to non-zero) only when there is a change in the file. This is to keep the margin minimal when diff-hl is the only one using it and the file has not been changed.

Thanks again

@dgutov
Copy link
Owner

dgutov commented Jun 23, 2024

Hi!

It's a bit of a hassle to save the "previous" width before updating, to restoring it when no indicators are needed. This kind of code could be error-prone.

But that aside, would you really want the margin width jumping back-and-forth? Consider that the whole text of the window will jump by 1 column (horizontally) when that happens. You add a new char, save - and the text shifts to the right. You remove that char and save (or commit the changes) - the text goes back left.

@haditim
Copy link
Author

haditim commented Jun 24, 2024

Hello again and thanks a lot for the reply.

I gave the git-gutter's Hide gutter if there are no changes a try and it wasn't bad, especially, in our case if we don't enable diff-hl-flydiff-mode and the "jump" only happens once you save the buffer. This provides more real estate on the sides for files which don't have a change. But if the implementation makes the code error-prone, I prefer the feature not to be there, especially if I am the only one who's asked for this. I like the stability of the package a lot.

Thanks again.

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

No branches or pull requests

2 participants