aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author朱李 <wanlisnx@gmail.com>2023-01-14 01:23:21 +0800
committerGitHub <noreply@github.com>2023-01-13 18:23:21 +0100
commitf07c1afea7dcff4011fba3f2e88a7f3225613564 (patch)
tree74452112f37e666995459d452a3bef7bfdd44fd7
parentdocs(changelog): copy_on_select = false fix (diff)
downloadsl0ppij-f07c1afea7dcff4011fba3f2e88a7f3225613564.tar.gz
sl0ppij-f07c1afea7dcff4011fba3f2e88a7f3225613564.tar.xz
sl0ppij-f07c1afea7dcff4011fba3f2e88a7f3225613564.zip
fix: wide-char drop on resize to 1 and invalid session names (#2082)
* fix: deny invalid session name * fix: `zellij attach --create SESSION_NAME` check session name * fix: drain_until(1) discard widechar * style(grid): add comment explaining the change Co-authored-by: Aram Drevekenin <aram@poor.dev>
-rw-r--r--src/commands.rs11
-rw-r--r--src/sessions.rs8
-rw-r--r--zellij-server/src/panes/grid.rs4
3 files changed, 18 insertions, 5 deletions
diff --git a/src/commands.rs b/src/commands.rs
index bf7cecb3..6d429cdb 100644
--- a/src/commands.rs
+++ b/src/commands.rs
@@ -324,6 +324,10 @@ pub(crate) fn start_client(opts: CliArgs) {
};
let os_input = get_os_input(get_client_os_input);
+ let start_client_plan = |session_name: std::string::String| {
+ assert_session_ne(&session_name);
+ };
+
if let Some(Command::Sessions(Sessions::Attach {
session_name,
create,
@@ -339,6 +343,9 @@ pub(crate) fn start_client(opts: CliArgs) {
let client = if let Some(idx) = index {
attach_with_session_index(config_options.clone(), idx, create)
} else {
+ if create {
+ session_name.clone().map(start_client_plan);
+ }
attach_with_session_name(session_name, config_options.clone(), create)
};
@@ -363,10 +370,6 @@ pub(crate) fn start_client(opts: CliArgs) {
attach_layout,
);
} else {
- let start_client_plan = |session_name: std::string::String| {
- assert_session_ne(&session_name);
- };
-
if let Some(session_name) = opts.session.clone() {
start_client_plan(session_name.clone());
start_client_impl(
diff --git a/src/sessions.rs b/src/sessions.rs
index 5a5c15d8..0ddcfcb2 100644
--- a/src/sessions.rs
+++ b/src/sessions.rs
@@ -202,6 +202,14 @@ pub(crate) fn assert_session_ne(name: &str) {
eprintln!("Session name cannot be empty. Please provide a specific session name.");
process::exit(1);
}
+ if name == "." || name == ".." {
+ eprintln!("Invalid session name: \"{}\".", name);
+ process::exit(1);
+ }
+ if name.contains('/') {
+ eprintln!("Session name cannot contains '/'.");
+ process::exit(1);
+ }
match session_exists(name) {
Ok(result) if !result => return,
diff --git a/zellij-server/src/panes/grid.rs b/zellij-server/src/panes/grid.rs
index b3ee85a4..b71687ea 100644
--- a/zellij-server/src/panes/grid.rs
+++ b/zellij-server/src/panes/grid.rs
@@ -3218,7 +3218,9 @@ impl Row {
let mut drained_part: VecDeque<TerminalCharacter> = VecDeque::new();
let mut drained_part_len = 0;
while let Some(next_character) = self.columns.remove(0) {
- if drained_part_len + next_character.width <= x {
+ // drained_part_len == 0 here is so that if the grid is resized
+ // to a size of 1, we won't drop wide characters
+ if drained_part_len + next_character.width <= x || drained_part_len == 0 {
drained_part.push_back(next_character);
drained_part_len += next_character.width;
} else {