Skip to content

Commit 8413519

Browse files
committed
use different states to disable buttons when there is no changes
1 parent 56881b8 commit 8413519

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

crates/git_ui/src/project_diff.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,7 @@ struct ButtonStates {
911911

912912
impl Render for ProjectDiffToolbar {
913913
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
914+
println!("{:?}", self.project_diff(cx));
914915
let Some(project_diff) = self.project_diff(cx) else {
915916
return div();
916917
};
@@ -947,7 +948,11 @@ impl Render for ProjectDiffToolbar {
947948
&StageAndNext,
948949
&focus_handle,
949950
))
950-
.disabled(!button_states.stage)
951+
.disabled(
952+
!button_states.prev_next
953+
&& !button_states.stage_all
954+
&& !button_states.unstage_all,
955+
)
951956
.on_click(cx.listener(|this, _, window, cx| {
952957
this.dispatch_action(&StageAndNext, window, cx)
953958
})),
@@ -959,7 +964,11 @@ impl Render for ProjectDiffToolbar {
959964
&UnstageAndNext,
960965
&focus_handle,
961966
))
962-
.disabled(!button_states.unstage)
967+
.disabled(
968+
!button_states.prev_next
969+
&& !button_states.stage_all
970+
&& !button_states.unstage_all,
971+
)
963972
.on_click(cx.listener(|this, _, window, cx| {
964973
this.dispatch_action(&UnstageAndNext, window, cx)
965974
})),

0 commit comments

Comments
 (0)