Skip to content

Commit

Permalink
add $.strict_tables to the config
Browse files Browse the repository at this point in the history
  • Loading branch information
amtoine committed Jul 14, 2024
1 parent 62eee55 commit 556797a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/config/default.nuon
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -164,6 +165,7 @@ impl Default for Config {
number: false,
relativenumber: false,
show_hints: true,
strict_tables: false,
colors: ColorConfig {
normal: TableRowColorConfig {
name: BgFgColorConfig {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 556797a

Please sign in to comment.