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
1 changed files with 12 additions and 7 deletions

View File

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