1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-11-28 07:46:28 +00:00

fix: Fix module configuration loading (#487)

This commit is contained in:
Zhenhui Xie 2019-10-05 17:21:48 +08:00 committed by Matan Kushner
parent 6c6e0ef1dd
commit bedf264a9f

View File

@ -80,15 +80,20 @@ impl<'a> Module<'a> {
let mut segment = Segment::new(name);
let segment_config_mock = SegmentConfig { value, style: None };
if let Some(module_config) = self.config {
let segment_config = segment_config_mock.load_config(&module_config);
segment.set_style(segment_config.style.unwrap_or(self.style));
segment.set_value(segment_config.value);
} else {
segment.set_style(segment_config_mock.style.unwrap_or(self.style));
segment.set_value(segment_config_mock.value);
if let Some(toml::Value::Table(module_config)) = self.config {
if let Some(symbol) = module_config.get(name) {
let segment_config = segment_config_mock.load_config(&symbol);
segment.set_style(segment_config.style.unwrap_or(self.style));
segment.set_value(segment_config.value);
self.segments.push(segment);
return self.segments.last_mut().unwrap();
}
}
segment.set_style(segment_config_mock.style.unwrap_or(self.style));
segment.set_value(segment_config_mock.value);
self.segments.push(segment);
self.segments.last_mut().unwrap()
}