Skip to content

Commit 9338d9d

Browse files
feat: make uppercase R toggle all patches for reply w/ Reviewed-by
Make hitting the uppercase `R` key result in all patches being (un)staged, depending if there are patches not staged to be replied (in this case, stage all) or not (in this case, unstage all). Signed-off-by: David Tadokoro <[email protected]>
1 parent 7ea0897 commit 9338d9d

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/app/screens/details_actions.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,16 @@ impl PatchsetDetailsAndActionsState {
106106
self.toggle_action(PatchsetAction::Bookmark);
107107
}
108108

109-
pub fn toggle_reply_with_reviewed_by_action(&mut self) {
110-
if let Some(entry) = self.patches_to_reply.get_mut(self.preview_index) {
109+
pub fn toggle_reply_with_reviewed_by_action(&mut self, all: bool) {
110+
if all {
111+
if self.patches_to_reply.contains(&false) {
112+
// If there is at least one patch not to be replied, set all to be
113+
self.patches_to_reply = vec![true; self.patches_to_reply.len()];
114+
} else {
115+
// If all patches are set to be replied, set none to be
116+
self.patches_to_reply = vec![false; self.patches_to_reply.len()];
117+
}
118+
} else if let Some(entry) = self.patches_to_reply.get_mut(self.preview_index) {
111119
*entry = !*entry;
112120
}
113121
if self.patches_to_reply.contains(&true) {

src/handler/details_actions.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ pub fn handle_patchset_details<B: Backend>(
2020
let patchset_details_and_actions = app.patchset_details_and_actions_state.as_mut().unwrap();
2121

2222
if key.modifiers.contains(KeyModifiers::SHIFT) {
23-
if let KeyCode::Char('G') = key.code {
24-
patchset_details_and_actions.go_to_last_line()
23+
match key.code {
24+
KeyCode::Char('G') => patchset_details_and_actions.go_to_last_line(),
25+
KeyCode::Char('R') => {
26+
patchset_details_and_actions.toggle_reply_with_reviewed_by_action(true);
27+
}
28+
_ => {}
2529
}
2630
return Ok(());
2731
}
@@ -86,7 +90,7 @@ pub fn handle_patchset_details<B: Backend>(
8690
patchset_details_and_actions.toggle_bookmark_action();
8791
}
8892
KeyCode::Char('r') => {
89-
patchset_details_and_actions.toggle_reply_with_reviewed_by_action();
93+
patchset_details_and_actions.toggle_reply_with_reviewed_by_action(false);
9094
}
9195
KeyCode::Enter => {
9296
if patchset_details_and_actions.actions_require_user_io() {

0 commit comments

Comments
 (0)