From f9d22cc35792537b5129802fdcfb3633db0a0e02 Mon Sep 17 00:00:00 2001 From: kumattau Date: Sun, 1 May 2022 17:12:31 +0900 Subject: [PATCH] Fix missing string after ";" from icon and window title --- termwiz/src/escape/osc.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/termwiz/src/escape/osc.rs b/termwiz/src/escape/osc.rs index d1b12bd90..736269af5 100644 --- a/termwiz/src/escape/osc.rs +++ b/termwiz/src/escape/osc.rs @@ -274,10 +274,13 @@ impl OperatingSystemCommand { macro_rules! single_string { ($variant:ident) => {{ - if osc.len() != 2 { + if osc.len() < 2 { bail!("wrong param count"); } - let s = String::from_utf8(osc[1].to_vec())?; + let mut s = String::from_utf8(osc[1].to_vec())?; + for i in 2..osc.len() { + s = [s, String::from_utf8(osc[i].to_vec())?].join(";"); + } Ok(OperatingSystemCommand::$variant(s)) }}; @@ -1285,18 +1288,20 @@ mod test { OperatingSystemCommand::SetIconNameAndWindowTitle("hello \u{1f915}".into()) ); + assert_eq!( + parse( + &["0", "hello \u{1f915}", " world"], + "\x1b]0;hello \u{1f915}; world\x1b\\" + ), + OperatingSystemCommand::SetIconNameAndWindowTitle("hello \u{1f915}; world".into()) + ); + // Missing title parameter assert_eq!( parse(&["0"], "\x1b]0\x1b\\"), OperatingSystemCommand::Unspecified(vec![b"0".to_vec()]) ); - // too many params - assert_eq!( - parse(&["0", "1", "2"], "\x1b]0;1;2\x1b\\"), - OperatingSystemCommand::Unspecified(vec![b"0".to_vec(), b"1".to_vec(), b"2".to_vec()]) - ); - // parsing legacy sun OSC; why bother? This format is used in response // to the CSI ReportWindowTitle sequence assert_eq!(