From bedf264a9ff5804584d3127aaac839ea6a6ba7ca Mon Sep 17 00:00:00 2001 From: Zhenhui Xie Date: Sat, 5 Oct 2019 17:21:48 +0800 Subject: [PATCH] fix: Fix module configuration loading (#487) --- src/module.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/module.rs b/src/module.rs index d14814eb..b06bf552 100644 --- a/src/module.rs +++ b/src/module.rs @@ -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() }