Visitar URL original
Inline git blame by mrnugget · Pull Request #10398 · zed-industries/zed · GitHub
Skip to content

Inline git blame - #10398

Merged
mrnugget merged 31 commits into
mainfrom
inline-git-blame
Apr 15, 2024
Merged

mrnugget merged 31 commits into
mainfrom
inline-git-blame

Conversation

@mrnugget

@mrnugget mrnugget commented Apr 11, 2024 •

Copy link
Copy Markdown
Contributor

This adds so-called "inline git blame" to the editor that, when turned on, shows git blame information about the current line inline:

screenshot-2024-04-15-11 29 35@2x

When the inline information is hovered, a new tooltip appears that contains more information on the current commit:

screenshot-2024-04-15-11 28 24@2x

The commit message in this tooltip is rendered as Markdown, is scrollable and clickable.

The tooltip is now also the tooltip used in the gutter:

screenshot-2024-04-15-11 28 51@2x

Settings

  1. The inline git blame information can be turned on and off via settings:
{
  "git": {
    "inline_blame": {
      "enabled": true
    }
  }
}
  1. Optionally, a delay can be configured. When a delay is set, the inline blame information will only show up x milliseconds after a cursor movement:
{
  "git": {
    "inline_blame": {
      "enabled": true,
      "delay_ms": 600
    }
  }
}
  1. It can also be turned on/off for the current buffer with editor: toggle git blame inline.

To be done in follow-up PRs

  • Add link to pull request in tooltip
  • Add avatars of users if possible

Release notes

Release Notes:

  • Added inline git blame information the editor. It's enabled by default. It can be turned off in the settings with {"git": { "inline_blame": {"enabled": false } } } for every buffer. It can be turned on/off temporarily for the current buffer, with editor: toggle git blame inline (#4793).

(These release notes include #10632)

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 11, 2024
@baldwindavid

baldwindavid commented Apr 11, 2024 •

Copy link
Copy Markdown
Contributor

Great stuff. I don't want to disrupt anything you have going on here, but just posting a couple things I wonder about for the future:

  • I really like inline blame tooltips, but don't tend to want to see it when moving throughout the code. I see a mention of "enable/disable", but assume that means a global on/off switch. I wonder if it would be possible to have a command allowing a keybinding to be assigned to display the tooltip similar to g h for editor::Hover.
  • "Add link to PR to tooltip" - This would be amazing to have at some point. As an aside, this is wayyyy outside the scope of this PR, but would generally like to be able to visit links in tooltips via keyboard.

@mrnugget

Copy link
Copy Markdown
Contributor Author

Thanks, David!

  • I wonder if it would be possible to have a command allowing a keybinding to be assigned to display the tooltip similar to g h for editor::Hover.

Yeah, that's a great idea, and we talked about it before: a push-to-talk kinda thing where you hold a key combination down and while it's down it shows the inline blame or something like that.

But before we do that, maybe we need global setting and a toggle keybinding, yeah.

mrnugget added a commit that referenced this pull request Apr 12, 2024
This introduces a new API on `StatefulInteractiveElement` to create a
tooltip that can be hovered, scrolled inside, and clicked:
`.hoverable_tooltip`.

Right now we only use it in the `git blame` gutter, but the plan is to
use the new hover/click/scroll behavior in #10398 to introduce new
git-blame-tooltips.

Release Notes:

- N/A

---------

Co-authored-by: Antonio <antonio@zed.dev>
@mrnugget
mrnugget marked this pull request as ready for review April 15, 2024 09:30
@mrnugget mrnugget mentioned this pull request Apr 15, 2024
5 tasks done
@mrnugget
mrnugget merged commit faebce8 into main Apr 15, 2024
@mrnugget
mrnugget deleted the inline-git-blame branch April 15, 2024 12:21
@mrnugget mrnugget mentioned this pull request Apr 15, 2024
1 task done
@Tenkir

Tenkir commented Apr 26, 2024

Copy link
Copy Markdown

This is cool, but is there a way to display it in the bottom toolbar (like VSCode). I pretty much never want to see it in the code itself.

@mrnugget

Copy link
Copy Markdown
Contributor Author

No, there isn't right now.

@Tenkir

Tenkir commented Apr 26, 2024 •

Copy link
Copy Markdown

All good, just wondering. I'd also be happy with the toggle hotkey baldwindavid mentioned above, so I'll throw a +1 behind that. As it is, it's too distracting so I just have it disabled. But I often want to know who wrote a function if I have questions about it, so it'd be super helpful to have a way to get this information on-demand.

@baldwindavid

Copy link
Copy Markdown
Contributor

@Tenkir you're probably aware but, if not, a bit of a workaround is to use the editor: toggle git blame command to pop open the blame only as needed rather than using "inline" blame at all. I have a keybinding to open/close that quickly.

  {
    "context": "Editor && VimControl && !VimWaiting && !menu",
    "bindings": {
      "space g l": "editor::ToggleGitBlame"
    }
}

@jay-herrera

Copy link
Copy Markdown

Hey! what is the relevant styling config for this feature? In my editor it shows up as super white, but I can't narrow down which config would change it

@mrnugget

mrnugget commented Jul 9, 2024

Copy link
Copy Markdown
Contributor Author

@jay-herrera it's using hint. You can override it like this:

{
  "experimental.theme_overrides": {
    "hint": "#fb4a35ff"
  }
}

@pavles6

pavles6 commented Jul 20, 2025

Copy link
Copy Markdown
Contributor

@mrnugget, is there a keymap action that can be mapped to display the tooltip that appears when an inline blame message is hovered? I want to be able to see the pop-up without having to move my mouse cursor.

jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…0466)

This introduces a new API on `StatefulInteractiveElement` to create a
tooltip that can be hovered, scrolled inside, and clicked:
`.hoverable_tooltip`.

Right now we only use it in the `git blame` gutter, but the plan is to
use the new hover/click/scroll behavior in zed-industries#10398 to introduce new
git-blame-tooltips.

Release Notes:

- N/A

---------

Co-authored-by: Antonio <antonio@zed.dev>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
This adds so-called "inline git blame" to the editor that, when turned
on, shows `git blame` information about the current line inline:


![screenshot-2024-04-15-11 29
35@2x](https://github.com/zed-industries/zed/assets/1185253/21cef7be-3283-4556-a9f0-cc349c4e1d75)


When the inline information is hovered, a new tooltip appears that
contains more information on the current commit:


![screenshot-2024-04-15-11 28
24@2x](https://github.com/zed-industries/zed/assets/1185253/ee128460-f6a2-48c2-a70d-e03ff90a737f)

The commit message in this tooltip is rendered as Markdown, is
scrollable and clickable.

The tooltip is now also the tooltip used in the gutter:

![screenshot-2024-04-15-11 28
51@2x](https://github.com/zed-industries/zed/assets/1185253/42be3d63-91d0-4936-8183-570e024beabe)


## Settings

1. The inline git blame information can be turned on and off via
settings:
```json
{
  "git": {
    "inline_blame": {
      "enabled": true
    }
  }
}
```
2. Optionally, a delay can be configured. When a delay is set, the
inline blame information will only show up `x milliseconds` after a
cursor movement:
```json
{
  "git": {
    "inline_blame": {
      "enabled": true,
      "delay_ms": 600
    }
  }
}
```
3. It can also be turned on/off for the current buffer with `editor:
toggle git blame inline`.

## To be done in follow-up PRs

- [ ] Add link to pull request in tooltip
- [ ] Add avatars of users if possible

## Release notes

Release Notes:

- Added inline `git blame` information the editor. It can be turned on
in the settings with `{"git": { "inline_blame": "on" } }` for every
buffer or, temporarily for the current buffer, with `editor: toggle git
blame inline`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants