From 556797aafbb41dfefec756b56206da1cfbedd471 Mon Sep 17 00:00:00 2001 From: amtoine Date: Sun, 14 Jul 2024 11:54:19 +0200 Subject: [PATCH] add `$.strict_tables` to the config --- examples/config/default.nuon | 1 + src/config/mod.rs | 7 +++++++ src/ui.rs | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/config/default.nuon b/examples/config/default.nuon index 2895c62..8da13c4 100644 --- a/examples/config/default.nuon +++ b/examples/config/default.nuon @@ -6,6 +6,7 @@ margin: 10, # the number of lines to keep between the cursor and the top / bottom number: false, # show line numbers relativenumber: false, # show line numbers, relative to the current one (overrides number) + strict_tables: false, # only render tables when all rows have the same keys with the same types # "reset" is used instead of "black" in a dark terminal because, when the terminal is actually # black, "black" is not really black which is ugly, whereas "reset" is really black. diff --git a/src/config/mod.rs b/src/config/mod.rs index 24a7482..9e38357 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -150,6 +150,7 @@ pub struct Config { pub number: bool, pub relativenumber: bool, pub show_hints: bool, + pub strict_tables: bool, } impl Default for Config { @@ -164,6 +165,7 @@ impl Default for Config { number: false, relativenumber: false, show_hints: true, + strict_tables: false, colors: ColorConfig { normal: TableRowColorConfig { name: BgFgColorConfig { @@ -304,6 +306,11 @@ impl Config { config.show_hints = val } } + "strict_tables" => { + if let Some(val) = try_bool(value, &["strict_tables"])? { + config.strict_tables = val + } + } "colors" => { let cell = follow_cell_path(value, &["colors"]).unwrap(); let columns = match &cell { diff --git a/src/ui.rs b/src/ui.rs index 3f9acf2..1e19cd6 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -238,7 +238,7 @@ fn render_data(frame: &mut Frame, app: &mut App) { let value = app.value_under_cursor(Some(CellPath { members: data_path })); - let table_type = is_table(&value, false); + let table_type = is_table(&value, !config.strict_tables); let is_a_table = matches!(table_type, crate::nu::value::Table::IsValid); let mut data_frame_height = if config.show_cell_path {