summaryrefslogtreecommitdiffstats
path: root/zellij-client/src
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2022-07-12 12:17:24 +0200
committerGitHub <noreply@github.com>2022-07-12 12:17:24 +0200
commit6e102c60842b4bda3fb11934968fddfa8de9eae5 (patch)
tree56f3b87a750cbdb1e0175d36bbf2c769c802c230 /zellij-client/src
parentee6a9cd78ecfd6693baed986cd6997745acf3962 (diff)
fix(cli): let the exit message be different when detaching (#1573)
* Let the exit message be different when detaching This patch changes the exit message printed to the user, so the user does not get the impression that they fat-fingered an "exit" instead of what was intended (a detach). For this, the InputHandler::exit() function was refactored, to get the reason as a parameter. As this function is not pub, this is considered okay. Signed-off-by: Matthias Beyer <mail@beyermatthias.de> * Change detach message This patch changes the detach message to be more in line with the other messages zellij displays to the user. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'zellij-client/src')
-rw-r--r--zellij-client/src/input_handler.rs22
1 files changed, 17 insertions, 5 deletions
diff --git a/zellij-client/src/input_handler.rs b/zellij-client/src/input_handler.rs
index 5f8cc0639..7428bac0f 100644
--- a/zellij-client/src/input_handler.rs
+++ b/zellij-client/src/input_handler.rs
@@ -189,6 +189,7 @@ impl InputHandler {
}
}
fn handle_actions(&mut self, actions: Vec<Action>, session_name: &str, clients: Vec<ClientId>) {
+ let mut detached = false;
for action in actions {
match action {
Action::Quit => {
@@ -200,6 +201,7 @@ impl InputHandler {
let last = clients.last().unwrap();
self.os_input
.send_to_server(ClientToServerMsg::DetachSession(vec![*first, *last]));
+ detached = true;
break;
},
// Actions, that are independent from the specific client
@@ -238,7 +240,11 @@ impl InputHandler {
self.dispatch_action(Action::Detach, None);
self.should_exit = true;
log::error!("Quitting Now. Dispatched the actions");
- self.exit();
+ if detached {
+ self.exit(ExitReason::NormalDetached);
+ } else {
+ self.exit(ExitReason::Normal);
+ }
}
/// Dispatches an [`Action`].
@@ -257,10 +263,16 @@ impl InputHandler {
match action {
Action::NoOp => {},
- Action::Quit | Action::Detach => {
+ Action::Quit => {
+ self.os_input
+ .send_to_server(ClientToServerMsg::Action(action, client_id));
+ self.exit(ExitReason::Normal);
+ should_break = true;
+ },
+ Action::Detach => {
self.os_input
.send_to_server(ClientToServerMsg::Action(action, client_id));
- self.exit();
+ self.exit(ExitReason::NormalDetached);
should_break = true;
},
Action::SwitchToMode(mode) => {
@@ -298,9 +310,9 @@ impl InputHandler {
/// Routine to be called when the input handler exits (at the moment this is the
/// same as quitting Zellij).
- fn exit(&mut self) {
+ fn exit(&mut self, reason: ExitReason) {
self.send_client_instructions
- .send(ClientInstruction::Exit(ExitReason::Normal))
+ .send(ClientInstruction::Exit(reason))
.unwrap();
}
}