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>
This commit is contained in:
parent
223b7a129c
commit
f07c1afea7
3 changed files with 18 additions and 5 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue