mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-09-21 16:58:19 +02:00
fix: use default disk.columns when only other disk.* configs exist (#1776)
I configured `[disk.name_filter]` and after upgrading to v0.11.0, the disk widget became empty since `disk.columns` was parsed as an empty vector unless I added `disk.columns` to my config as well.
This commit is contained in:
parent
c17110caf2
commit
9fe558183b
@ -407,7 +407,7 @@ pub(crate) fn init_app(args: BottomArgs, config: Config) -> Result<(App, BottomL
|
||||
DiskTableWidget::new(
|
||||
&app_config_fields,
|
||||
&styling,
|
||||
config.disk.as_ref().map(|cfg| cfg.columns.as_slice()),
|
||||
config.disk.as_ref().and_then(|cfg| cfg.columns.as_deref()),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ pub(crate) struct DiskConfig {
|
||||
|
||||
/// A list of disk widget columns.
|
||||
#[serde(default)]
|
||||
pub(crate) columns: Vec<DiskColumn>, // TODO: make this more composable(?) in the future, we might need to rethink how it's done for custom widgets
|
||||
pub(crate) columns: Option<Vec<DiskColumn>>, // TODO: make this more composable(?) in the future, we might need to rethink how it's done for custom widgets
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -24,10 +24,17 @@ mod test {
|
||||
use super::DiskConfig;
|
||||
|
||||
#[test]
|
||||
fn empty_column_setting() {
|
||||
fn none_column_setting() {
|
||||
let config = "";
|
||||
let generated: DiskConfig = toml_edit::de::from_str(config).unwrap();
|
||||
assert!(generated.columns.is_empty());
|
||||
assert!(generated.columns.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_column_setting() {
|
||||
let config = r#"columns = []"#;
|
||||
let generated: DiskConfig = toml_edit::de::from_str(config).unwrap();
|
||||
assert!(generated.columns.unwrap().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
x
Reference in New Issue
Block a user