mirror of
https://github.com/starship/starship.git
synced 2025-02-24 22:32:39 +01:00
fix: Don't print the first module prefix after a line-break (#473)
This commit is contained in:
parent
ab5dae3d05
commit
77c25b60c2
@ -127,6 +127,11 @@ impl<'a> Module<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get module's name
|
||||||
|
pub fn get_name(&self) -> &String {
|
||||||
|
&self._name
|
||||||
|
}
|
||||||
|
|
||||||
/// Whether a module has non-empty segments
|
/// Whether a module has non-empty segments
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.segments.iter().all(|segment| segment.is_empty())
|
self.segments.iter().all(|segment| segment.is_empty())
|
||||||
|
18
src/print.rs
18
src/print.rs
@ -41,16 +41,20 @@ pub fn prompt(args: ArgMatches) {
|
|||||||
.flatten()
|
.flatten()
|
||||||
.collect::<Vec<Module>>(); // Remove segments set to `None`
|
.collect::<Vec<Module>>(); // Remove segments set to `None`
|
||||||
|
|
||||||
|
let mut print_without_prefix = true;
|
||||||
let mut printable = modules.iter();
|
let mut printable = modules.iter();
|
||||||
|
|
||||||
// Print the first module without its prefix
|
for module in printable {
|
||||||
if let Some(first_module) = printable.next() {
|
// Skip printing the prefix of a module after the line_break
|
||||||
let module_without_prefix = first_module.to_string_without_prefix();
|
if print_without_prefix {
|
||||||
write!(handle, "{}", module_without_prefix).unwrap()
|
let module_without_prefix = module.to_string_without_prefix();
|
||||||
}
|
write!(handle, "{}", module_without_prefix).unwrap()
|
||||||
|
} else {
|
||||||
|
write!(handle, "{}", module).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
// Print all remaining modules
|
print_without_prefix = module.get_name() == "line_break"
|
||||||
printable.for_each(|module| write!(handle, "{}", module).unwrap());
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn module(module_name: &str, args: ArgMatches) {
|
pub fn module(module_name: &str, args: ArgMatches) {
|
||||||
|
Loading…
Reference in New Issue
Block a user