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

Improve discoverability around closing git diffs #12404

Closed
1 task done
Morgandri1 opened this issue May 29, 2024 · 11 comments · Fixed by #14727
Closed
1 task done

Improve discoverability around closing git diffs #12404

Morgandri1 opened this issue May 29, 2024 · 11 comments · Fixed by #14727
Labels
discoverability Feedback for discoverability of features, settings, etc editor Feedback for code editing, formatting, editor iterations, etc enhancement [core label] git Git integration feedback mouse interaction Feedback for mouse interaction states, actions, etc

Comments

@Morgandri1
Copy link

Check for existing issues

  • Completed

Describe the feature

Hello!
When you open a git diff on a line, there isn't a [easy] way to close the diff. An 'x' button, or something similar to the close diagnostic button would be much appreciated

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

Screenshot 3
@Morgandri1 Morgandri1 added admin read Pending admin review enhancement [core label] triage Maintainer needs to classify the issue labels May 29, 2024
@Morgandri1
Copy link
Author

in hindsight I guess the button should be in the current version, but 🤷

@jtlandis
Copy link

I also agree that there should be a button. After a bit of searching, I found that pressing CMD+' while your cursor is on the added line (in your case line 70) should close the git diff.

@Morgandri1
Copy link
Author

Although convoluted, thank you Jason! I think this is probably a pretty good first issue?

@Moshyfawn
Copy link
Member

There's also the Esc key and the editor: toggle hunk diff action in the command panel. I'm not sure how the team feels about a button, though.

@Morgandri1
Copy link
Author

didn't know about the esc keybind. good to know.

imo if there's a dismiss button for the error diagnostic, there should be one here, but thats just me.

@Moshyfawn Moshyfawn added editor Feedback for code editing, formatting, editor iterations, etc git Git integration feedback and removed triage Maintainer needs to classify the issue labels May 29, 2024
@JosephTLyons JosephTLyons removed the admin read Pending admin review label May 29, 2024
@JosephTLyons JosephTLyons changed the title No way to close git diff Improve discoverability around closing git diffs May 29, 2024
@Moshyfawn Moshyfawn added the discoverability Feedback for discoverability of features, settings, etc label May 29, 2024
@someone13574
Copy link
Contributor

Maybe you could keep showing the git gutter and have clicking that toggle it off, just like you can toggle it on by clicking the git gutter?

@Morgandri1
Copy link
Author

Not a bad idea; Would the gutter expand or only show on the current?

@someone13574
Copy link
Contributor

I’d say only show for the current code, with the same colour as when it is unexpanded.

@Morgandri1
Copy link
Author

So I was able to get the git gutter to stay when opened, but can't figure out how to close it.

Would appreciate some help
https://github.com/Morgandri1/zed

@SomeoneToIgnore
Copy link
Contributor

SomeoneToIgnore commented Jun 13, 2024

To show the X mark in the gutter, here's a set of pointers:

  • Zed is already able to combine LSP actions (lightning icon in the gutter) and tasks (triangle icon in the gutter) under the same entry, and can replace one icon with another, if tasks are mixed.
    Here's how tasks' icon is added:
    let button = prepaint_gutter_button(

    we could add another X icon similar way for every added and modified hunk.

In the editor element, when we paint the gutter during fn paint_gutter, we have all its layout.display_hunks — whatever one has the hitbox is clickable ergo folded (as the code works now), otherwise it's expanded.

Self::paint_diff_hunks(layout.gutter_hitbox.bounds, layout, cx)

We can add another icon below for every expanded hunk, similar to test_indicators and indicator:

cx.paint_layer(layout.gutter_hitbox.bounds, |cx| {
cx.with_element_namespace("gutter_fold_toggles", |cx| {
for fold_indicator in layout.gutter_fold_toggles.iter_mut().flatten() {
fold_indicator.paint(cx);
}
});
for test_indicators in layout.test_indicators.iter_mut() {
test_indicators.paint(cx);
}
if let Some(indicator) = layout.code_actions_indicator.as_mut() {
indicator.paint(cx);
}
});

  • Deleted hunks are harder, as those open a separate, nested editor and push down the real gutter — X mark has to be placed inside that editor's gutter instead.
    For deleted hunks' editors, we now draw a fake space padded with the gutter size instead of the real gutter:

    .pl(gutter_dimensions.full_width())

    we can add an X icon straight there and toggle the hunk folding for parent editor from there.

  • To fold an expanded hunk, one has to remove it from the editor.expanded_hunks collection and clear row highlights and/or sub-editors, similar to how toggle_hunks_expanded method does it:

    highlights_to_remove.push(expanded_hunk.hunk_range.clone());
    blocks_to_remove.extend(expanded_hunk.block);
    hunks_to_toggle.next();
    retain = false;
    break;

@Angelk90

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discoverability Feedback for discoverability of features, settings, etc editor Feedback for code editing, formatting, editor iterations, etc enhancement [core label] git Git integration feedback mouse interaction Feedback for mouse interaction states, actions, etc
Projects
None yet
8 participants