feat: add diff gutter to picker preview - #14538
Open
forivall wants to merge 6 commits into
Open
Conversation
forivall
commented
Oct 5, 2025
Comment on lines
+977
to
+1012
| let gutter_style = theme.get("ui.gutter"); | ||
| let gutter_style_virtual = theme.get("ui.gutter.virtual"); | ||
|
|
||
| let mut gutter = gutter::diff_style(doc, theme); | ||
| // equivalent to helix_view::editor::GutterType::Diff.width(_, doc); | ||
| let width = 1; | ||
| // avoid lots of small allocations by reusing a text buffer for each line | ||
| let mut text = String::with_capacity(width); | ||
| let gutter_decoration = move |renderer: &mut TextRenderer, pos: LinePos| { | ||
| // draw over the margin with width | ||
| let x = inner.x - 1; | ||
| let y = pos.visual_line; | ||
|
|
||
| let gutter_style = match pos.first_visual_line { | ||
| true => gutter_style, | ||
| false => gutter_style_virtual, | ||
| }; | ||
|
|
||
| if let Some(style) = | ||
| gutter(pos.doc_line, false, pos.first_visual_line, &mut text) | ||
| { | ||
| renderer.set_stringn(x, y, &text, width, gutter_style.patch(style)); | ||
| } else { | ||
| renderer.set_style( | ||
| Rect { | ||
| x, | ||
| y, | ||
| width: width as u16, | ||
| height: 1, | ||
| }, | ||
| gutter_style, | ||
| ); | ||
| } | ||
| text.clear(); | ||
| }; | ||
| decorations.add_decoration(gutter_decoration); |
Contributor
Author
There was a problem hiding this comment.
adapted from
helix/helix-term/src/ui/editor.rs
Lines 671 to 706 in 6fffaf6
Contributor
|
I think this does need to be configurable, because the normal diff gutter can already be hidden. It would be weird if a normal buffer doesn't have the diff gutter while the picker has. Maybe it could read the existing |
forivall
force-pushed
the
diff-gutter-preview
branch
from
February 20, 2026 23:29
da3007d to
42ab4b2
Compare
forivall
force-pushed
the
diff-gutter-preview
branch
from
February 28, 2026 02:40
42ab4b2 to
52a8871
Compare
forivall
force-pushed
the
diff-gutter-preview
branch
from
August 12, 2026 00:37
52a8871 to
de0e899
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This could probably be improved with some configuration options, if desired.
Screenshot taken from my branch with a few other modifications, notably this hack: forivall@c37b18d4 to select the first change in the git diff picker.