fix: Wrap prefix and suffix in shell-specific escape codes (#712)

This commit is contained in:
Brian Low 2019-12-13 12:35:10 -07:00 committed by Matan Kushner
parent 7ab473c88c
commit 12e8ae85dd
1 changed files with 5 additions and 5 deletions

View File

@ -121,21 +121,21 @@ impl<'a> Module<'a> {
/// `ANSIStrings()` to optimize ANSI codes /// `ANSIStrings()` to optimize ANSI codes
pub fn ansi_strings(&self) -> Vec<ANSIString> { pub fn ansi_strings(&self) -> Vec<ANSIString> {
let shell = std::env::var("STARSHIP_SHELL").unwrap_or_default(); let shell = std::env::var("STARSHIP_SHELL").unwrap_or_default();
let ansi_strings = self let mut ansi_strings = self
.segments .segments
.iter() .iter()
.map(Segment::ansi_string) .map(Segment::ansi_string)
.collect::<Vec<ANSIString>>(); .collect::<Vec<ANSIString>>();
let mut ansi_strings = match shell.as_str() { ansi_strings.insert(0, self.prefix.ansi_string());
ansi_strings.push(self.suffix.ansi_string());
ansi_strings = match shell.as_str() {
"bash" => ansi_strings_modified(ansi_strings, shell), "bash" => ansi_strings_modified(ansi_strings, shell),
"zsh" => ansi_strings_modified(ansi_strings, shell), "zsh" => ansi_strings_modified(ansi_strings, shell),
_ => ansi_strings, _ => ansi_strings,
}; };
ansi_strings.insert(0, self.prefix.ansi_string());
ansi_strings.push(self.suffix.ansi_string());
ansi_strings ansi_strings
} }