summaryrefslogtreecommitdiffstats
path: root/zellij-utils
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2021-09-27 11:29:13 +0200
committerGitHub <noreply@github.com>2021-09-27 11:29:13 +0200
commit5c54bf18c21e60d82ef063b62337f6b545d914d3 (patch)
tree4af736bfd7b05ae2402930f8f41e3e9f669d3a6f /zellij-utils
parentc93a4f1f67d04750dfc883d01a8d58b44f493a43 (diff)
feat(sessions): mirrored sessions (#740)
* feat(sessions): mirrored sessions * fix(tests): input units * style(fmt): make rustfmt happy * fix(tests): make mirrored sessions e2e test more robust * refactor(sessions): remove force attach * style(fmt): rustfmtify * docs(changelog): update change * fix(e2e): retry on all errors
Diffstat (limited to 'zellij-utils')
-rw-r--r--zellij-utils/src/cli.rs5
-rw-r--r--zellij-utils/src/errors.rs33
-rw-r--r--zellij-utils/src/ipc.rs9
3 files changed, 38 insertions, 9 deletions
diff --git a/zellij-utils/src/cli.rs b/zellij-utils/src/cli.rs
index eb52589ae..452033b8a 100644
--- a/zellij-utils/src/cli.rs
+++ b/zellij-utils/src/cli.rs
@@ -81,11 +81,6 @@ pub enum Sessions {
/// Name of the session to attach to.
session_name: Option<String>,
- /// Force attach- session will detach from the other
- /// zellij client (if any) and attach to this.
- #[structopt(long, short)]
- force: bool,
-
/// Create a session if one does not exist.
#[structopt(short, long)]
create: bool,
diff --git a/zellij-utils/src/errors.rs b/zellij-utils/src/errors.rs
index 87c3bb4dc..dc9a97890 100644
--- a/zellij-utils/src/errors.rs
+++ b/zellij-utils/src/errors.rs
@@ -60,8 +60,37 @@ where
),
};
+ let one_line_backtrace = match (info.location(), msg) {
+ (Some(location), Some(msg)) => format!(
+ "{}\n\u{1b}[0;0mError: \u{1b}[0;31mthread '{}' panicked at '{}': {}:{}\n\u{1b}[0;0m",
+ err_ctx,
+ thread,
+ msg,
+ location.file(),
+ location.line(),
+ ),
+ (Some(location), None) => format!(
+ "{}\n\u{1b}[0;0mError: \u{1b}[0;31mthread '{}' panicked: {}:{}\n\u{1b}[0;0m",
+ err_ctx,
+ thread,
+ location.file(),
+ location.line(),
+ ),
+ (None, Some(msg)) => format!(
+ "{}\n\u{1b}[0;0mError: \u{1b}[0;31mthread '{}' panicked at '{}'\n\u{1b}[0;0m",
+ err_ctx, thread, msg
+ ),
+ (None, None) => format!(
+ "{}\n\u{1b}[0;0mError: \u{1b}[0;31mthread '{}' panicked\n\u{1b}[0;0m",
+ err_ctx, thread
+ ),
+ };
+
if thread == "main" {
- println!("{}", backtrace);
+ // here we only show the first line because the backtrace is not readable otherwise
+ // a better solution would be to escape raw mode before we do this, but it's not trivial
+ // to get os_input here
+ println!("\u{1b}[2J{}", one_line_backtrace);
process::exit(1);
} else {
let _ = sender.send(T::error(backtrace));
@@ -262,6 +291,7 @@ pub enum ClientContext {
UnblockInputThread,
Render,
ServerError,
+ SwitchToMode,
}
/// Stack call representations corresponding to the different types of [`ServerInstruction`]s.
@@ -271,6 +301,7 @@ pub enum ServerContext {
Render,
UnblockInputThread,
ClientExit,
+ RemoveClient,
Error,
DetachSession,
AttachClient,
diff --git a/zellij-utils/src/ipc.rs b/zellij-utils/src/ipc.rs
index 1b883d2a2..5c327022f 100644
--- a/zellij-utils/src/ipc.rs
+++ b/zellij-utils/src/ipc.rs
@@ -16,7 +16,7 @@ use std::{
os::unix::io::{AsRawFd, FromRawFd},
};
-use zellij_tile::data::Palette;
+use zellij_tile::data::{InputMode, Palette};
type SessionId = u64;
@@ -65,7 +65,7 @@ pub enum ClientToServerMsg {
LayoutFromYaml,
Option<PluginsConfig>,
),
- AttachClient(ClientAttributes, bool, Options),
+ AttachClient(ClientAttributes, Options),
Action(Action),
ClientExited,
}
@@ -80,6 +80,7 @@ pub enum ServerToClientMsg {
Render(String),
UnblockInputThread,
Exit(ExitReason),
+ SwitchToMode(InputMode),
}
#[derive(Serialize, Deserialize, Debug, Clone)]
@@ -126,7 +127,9 @@ impl<T: Serialize> IpcSenderWithContext<T> {
pub fn send(&mut self, msg: T) {
let err_ctx = get_current_ctx();
bincode::serialize_into(&mut self.sender, &(msg, err_ctx)).unwrap();
- self.sender.flush().unwrap();
+ // TODO: unwrapping here can cause issues when the server disconnects which we don't mind
+ // do we need to handle errors here in other cases?
+ let _ = self.sender.flush();
}
/// Returns an [`IpcReceiverWithContext`] with the same socket as this sender.