1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-14 03:16:09 +03:00

fix winget list causes toast notification spam

https://github.com/wez/wezterm/pull/1939 caused the ConEMU OSC 9
escapes
<https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC>
to be interpreted as toast notification escapes.

This commit restores the nature of the `single_string` macro to validate
the number of OSC parameters by default, but allow the string combining
just for the unambiguous title related OSC codes.

refs: https://github.com/wez/wezterm/issues/2185
This commit is contained in:
Wez Furlong 2022-06-26 16:54:05 -07:00
parent 9dc1989282
commit 67311ebda7

View File

@ -273,6 +273,16 @@ impl OperatingSystemCommand {
.ok_or_else(|| format!("unknown code"))?;
macro_rules! single_string {
($variant:ident) => {{
if osc.len() != 2 {
bail!("wrong param count");
}
let s = String::from_utf8(osc[1].to_vec())?;
Ok(OperatingSystemCommand::$variant(s))
}};
}
macro_rules! single_title_string {
($variant:ident) => {{
if osc.len() < 2 {
bail!("wrong param count");
@ -288,13 +298,13 @@ impl OperatingSystemCommand {
use self::OperatingSystemCommandCode::*;
match osc_code {
SetIconNameAndWindowTitle => single_string!(SetIconNameAndWindowTitle),
SetWindowTitle => single_string!(SetWindowTitle),
SetIconNameAndWindowTitle => single_title_string!(SetIconNameAndWindowTitle),
SetWindowTitle => single_title_string!(SetWindowTitle),
SetWindowTitleSun => Ok(OperatingSystemCommand::SetWindowTitleSun(
p1str[1..].to_owned(),
)),
SetIconName => single_string!(SetIconName),
SetIconName => single_title_string!(SetIconName),
SetIconNameSun => Ok(OperatingSystemCommand::SetIconNameSun(
p1str[1..].to_owned(),
)),