forked from extern/nushell
Display empty records and lists (#7925)
# Description Fix some issues related to #7444 1. Empty lists and records are now displayed as a small notice in a box:   2. Empty records are now correctly displayed if inside of another record list or table:   3. Fixed inconsistent coloring of empty list placeholder inside of lists/tables:   # User-Facing Changes `table` command now displays empty records and lists like a table with text and correctly displays empty records inside tables and lists. New behavior of displaying empty lists and records can be disabled using `table.show_empty` config option. # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date.
This commit is contained in:
@ -65,6 +65,7 @@ pub struct Config {
|
||||
pub external_completer: Option<usize>,
|
||||
pub filesize_metric: bool,
|
||||
pub table_mode: String,
|
||||
pub table_show_empty: bool,
|
||||
pub use_ls_colors: bool,
|
||||
pub color_config: HashMap<String, Value>,
|
||||
pub use_grid_icons: bool,
|
||||
@ -106,6 +107,7 @@ impl Default for Config {
|
||||
Config {
|
||||
filesize_metric: false,
|
||||
table_mode: "rounded".into(),
|
||||
table_show_empty: true,
|
||||
external_completer: None,
|
||||
use_ls_colors: true,
|
||||
color_config: HashMap::new(),
|
||||
@ -885,6 +887,9 @@ impl Value {
|
||||
}
|
||||
}
|
||||
}
|
||||
"show_empty" => {
|
||||
try_bool!(cols, vals, index, span, table_show_empty)
|
||||
}
|
||||
x => {
|
||||
invalid_key!(
|
||||
cols,
|
||||
|
@ -96,6 +96,35 @@ impl Type {
|
||||
Type::Signature => SyntaxShape::Signature,
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a string representation, without inner type specification of lists,
|
||||
/// tables and records (get `list` instead of `list<any>`
|
||||
pub fn get_non_specified_string(&self) -> String {
|
||||
match self {
|
||||
Type::Block => String::from("block"),
|
||||
Type::Closure => String::from("closure"),
|
||||
Type::Bool => String::from("bool"),
|
||||
Type::CellPath => String::from("cell path"),
|
||||
Type::Date => String::from("date"),
|
||||
Type::Duration => String::from("duration"),
|
||||
Type::Filesize => String::from("filesize"),
|
||||
Type::Float => String::from("float"),
|
||||
Type::Int => String::from("int"),
|
||||
Type::Range => String::from("range"),
|
||||
Type::Record(_) => String::from("record"),
|
||||
Type::Table(_) => String::from("table"),
|
||||
Type::List(_) => String::from("list"),
|
||||
Type::Nothing => String::from("nothing"),
|
||||
Type::Number => String::from("number"),
|
||||
Type::String => String::from("string"),
|
||||
Type::ListStream => String::from("list stream"),
|
||||
Type::Any => String::from("any"),
|
||||
Type::Error => String::from("error"),
|
||||
Type::Binary => String::from("binary"),
|
||||
Type::Custom(_) => String::from("custom"),
|
||||
Type::Signature => String::from("signature"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Type {
|
||||
|
Reference in New Issue
Block a user