Support hunk-wise StageAndNext and UnstageAndNext (#25845)

This PR adds the `whole_excerpt` field to the actions:

- `git::StageAndNext`
- `git::UnstageAndNext`

Which is set by false by default, effectively, now staging and unstaging
with these actions is done hunk-by-hunk, this also affects the `Stage`
and
`Unstage` buttons in the Diff View toolbar.

A caveat: with this PR, there is no way to configure the buttons in the
Diff
View toolbar to restore the previous behavior, if we want, I think we
can make
it a setting, but let's see if anyone really wants that.

Release Notes:

- N/A
This commit is contained in:
João Marcos 2025-02-28 23:39:08 -03:00 committed by GitHub
parent 13deaa3f69
commit a2876f5d3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 93 additions and 35 deletions

View file

@ -813,7 +813,9 @@ impl Render for ProjectDiffToolbar {
Button::new("stage", "Stage")
.tooltip(Tooltip::for_action_title_in(
"Stage",
&StageAndNext,
&StageAndNext {
whole_excerpt: false,
},
&focus_handle,
))
// don't actually disable the button so it's mashable
@ -823,14 +825,22 @@ impl Render for ProjectDiffToolbar {
Color::Disabled
})
.on_click(cx.listener(|this, _, window, cx| {
this.dispatch_action(&StageAndNext, window, cx)
this.dispatch_action(
&StageAndNext {
whole_excerpt: false,
},
window,
cx,
)
})),
)
.child(
Button::new("unstage", "Unstage")
.tooltip(Tooltip::for_action_title_in(
"Unstage",
&UnstageAndNext,
&UnstageAndNext {
whole_excerpt: false,
},
&focus_handle,
))
.color(if button_states.unstage {
@ -839,7 +849,13 @@ impl Render for ProjectDiffToolbar {
Color::Disabled
})
.on_click(cx.listener(|this, _, window, cx| {
this.dispatch_action(&UnstageAndNext, window, cx)
this.dispatch_action(
&UnstageAndNext {
whole_excerpt: false,
},
window,
cx,
)
})),
)
}),