zed icon indicating copy to clipboard operation
zed copied to clipboard

Position inline-git-blame information at column count

Open jansol opened this issue 1 year ago • 6 comments

Check for existing issues

  • [X] Completed

Describe the feature

This is more of a "UI exploration" thing, I'm not sure yet if it's actually a good idea.

How about an option to constrain the inline git blame to a certain column position? I would consider setting it to never appear to the left of the first line wrap guide (80 cols in my config).

The motivation for this is to avoid causing a seemingly solid block of text when the cursor is on a short line between long lines (e.g. a paragraph break in a long comment)

If applicable, add mockups / screenshots to help present your vision of the feature

No response

jansol avatar Apr 15 '24 13:04 jansol

That should be relatively easy.

  1. Define a setting for this
  2. Use min(line_width, settings.inline_blame_column*em_width) here: https://github.com/zed-industries/zed/blob/f4f9ca0b1e32f085a8f0ec631b635caf863a9ba1/crates/editor/src/element.rs#L1141

mrnugget avatar Apr 15 '24 13:04 mrnugget

Should be max, not min, but that does indeed do exactly what I described. Most of the work would be adding the setting.

An interesting extension of this would be to snap to the lowest indent guide that is > line length + padding.

jansol avatar Apr 15 '24 14:04 jansol

Ah, except that logic makes it go out of view if the line is soft-wrapped (e.g. due to inlay hints making it longer than desired). In that case the blame should probably be moved to the last line of the soft-wrapped part.

jansol avatar Apr 15 '24 15:04 jansol

Ah, except that logic makes it go out of view if the line is soft-wrapped (e.g. due to inlay hints making it longer than desired). In that case the blame should probably be moved to the last line of the soft-wrapped part.

In https://github.com/zed-industries/zed/pull/10600 I just added support for soft-wrapped lines (it was just broken before). It's now displayed next to each wrapped line, which I think makes sense when you think about the "soft_wrap": "preferred_line_length" case, where each line could be cut off at 80 cols.

mrnugget avatar Apr 16 '24 08:04 mrnugget

Hey, can i work on this ? I am new to contributing to Open Source, so would be helpful if there was a manifest of what to do, i believe all the git blame functionality is in the blame.rs file of git crate?

hshreekar avatar Apr 16 '24 19:04 hshreekar

@hshreekar sure, I linked to the code that needs to be edited above.

  1. Add a git.inline_blame.min_column setting to ProjectSettings (an Option<u32>?)
  2. In the code that I linked above, access the project settings
  3. Use max(line_width, git.inline_blame.min_column) if min_column is set

mrnugget avatar Apr 17 '24 07:04 mrnugget

This landed in v0.133.0-pre today. Closing this out.

JosephTLyons avatar Apr 24 '24 20:04 JosephTLyons