mirror of
https://github.com/nushell/nushell
synced 2025-01-13 13:49:21 +00:00
Add small refactorings
This commit is contained in:
parent
b5b523f314
commit
25a5fca41d
2 changed files with 11 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
||||||
use nu_ansi_term::Style;
|
use nu_ansi_term::Style;
|
||||||
use nu_color_config::StyleComputer;
|
use nu_color_config::StyleComputer;
|
||||||
use nu_protocol::{Config, Record, Value};
|
use nu_protocol::{Config, Value};
|
||||||
use nu_utils::SharedCow;
|
use nu_utils::SharedCow;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -51,7 +51,7 @@ fn colorize_value(value: &mut Value, config: &Config, style_computer: &StyleComp
|
||||||
|
|
||||||
(header, val)
|
(header, val)
|
||||||
})
|
})
|
||||||
.collect::<Record>(),
|
.collect(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Value::List { vals, .. } => {
|
Value::List { vals, .. } => {
|
||||||
|
|
|
@ -60,10 +60,7 @@ fn build_table(
|
||||||
DimensionPriority::Last,
|
DimensionPriority::Last,
|
||||||
));
|
));
|
||||||
|
|
||||||
// color_config closures for "separator" are just given a null.
|
if let Some(color) = get_border_color(style) {
|
||||||
let color = style.compute("separator", &Value::nothing(Span::unknown()));
|
|
||||||
let color = color.paint(" ").to_string();
|
|
||||||
if let Ok(color) = Color::try_from(color) {
|
|
||||||
if !is_color_empty(&color) {
|
if !is_color_empty(&color) {
|
||||||
return build_table_with_border_color(table, color);
|
return build_table_with_border_color(table, color);
|
||||||
}
|
}
|
||||||
|
@ -348,3 +345,11 @@ impl<R, D> TableOption<R, CompactMultilineConfig, D> for SetBorderColor {
|
||||||
cfg.set_borders_color(borders);
|
cfg.set_borders_color(borders);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_border_color(style: &StyleComputer<'_>) -> Option<Color> {
|
||||||
|
// color_config closures for "separator" are just given a null.
|
||||||
|
let color = style.compute("separator", &Value::nothing(Span::unknown()));
|
||||||
|
let color = color.paint(" ").to_string();
|
||||||
|
let color = Color::try_from(color);
|
||||||
|
color.ok()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue