nu-table: Fix header style (again 2x) (#6073)

* nu-table: Fix header style

It did appeared again after my small change...

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>

* nu-table: Add a empty header style test

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
This commit is contained in:
Maxim Zhiburt
2022-07-18 19:45:21 +03:00
committed by GitHub
parent eeaca50dee
commit 41669e60c8
5 changed files with 49 additions and 12 deletions

View File

@ -257,7 +257,12 @@ fn load_theme(
with_footer: bool,
with_header: bool,
) -> tabled::Table {
table = table.with(theme.theme.clone());
let mut theme = theme.theme.clone();
if !with_header {
theme.set_lines(HashMap::default());
}
table = table.with(theme);
if let Some(color) = color_hm.get("separator") {
let color = color.paint(" ").to_string();
@ -274,10 +279,6 @@ fn load_theme(
);
}
if !with_header {
table = table.with(RemoveHeaderLine);
}
table
}

View File

@ -1,4 +1,4 @@
use tabled::{papergrid::Line, style::RawStyle, Style};
use tabled::style::{Line, RawStyle, Style};
#[derive(Debug, Clone)]
pub struct TableTheme {
@ -20,7 +20,9 @@ impl TableTheme {
pub fn light() -> TableTheme {
Self {
theme: Style::blank().lines([(1, Line::short('─', '─'))]).into(),
theme: Style::blank()
.lines([(1, Line::new(Some('─'), Some('─'), None, None))])
.into(),
}
}
@ -41,7 +43,7 @@ impl TableTheme {
.top('❤')
.bottom('❤')
.vertical('❤')
.lines([(1, Line::short('❤', '❤'))])
.lines([(1, Line::new(Some('❤'), Some('❤'), None, None))])
.into(),
}
}