fix(cli): fallback to plain prompt on VTE terminals with broken emoji width (#8385)
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Signed-off-by: Douwe Osinga <douwe@squareup.com> Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -400,9 +400,23 @@ fn parse_plan_command(input: String) -> Option<InputResult> {
|
||||
}
|
||||
|
||||
fn get_input_prompt_string() -> String {
|
||||
if is_vte_with_broken_emoji_width() {
|
||||
return "> ".to_string();
|
||||
}
|
||||
"🪿 ".to_string()
|
||||
}
|
||||
|
||||
/// VTE < 0.70 renders 🪿 as 1 cell while unicode-width counts 2, causing cursor offset.
|
||||
fn is_vte_with_broken_emoji_width() -> bool {
|
||||
let Ok(vte_version) = std::env::var("VTE_VERSION") else {
|
||||
return false;
|
||||
};
|
||||
let Ok(version) = vte_version.parse::<u32>() else {
|
||||
return true;
|
||||
};
|
||||
version < 7000
|
||||
}
|
||||
|
||||
fn print_help() {
|
||||
let newline_key = get_newline_key().to_ascii_uppercase();
|
||||
let modes = GooseMode::VARIANTS.join(", ");
|
||||
|
||||
Reference in New Issue
Block a user