nu-table/ Fix indexing issue for table --expand (#9484)

close #9481

---------

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
This commit is contained in:
Maxim Zhiburt
2023-06-20 11:27:00 +03:00
committed by GitHub
parent 69bf43ef56
commit 2ec1364925
4 changed files with 27 additions and 6 deletions

View File

@ -2369,3 +2369,19 @@ fn _split_str_by_width(s: &str, w: usize) -> Vec<String> {
lines
}
#[test]
fn table_expand_index_offset() {
let actual = nu!(r#"1..1002 | table --expand"#);
let suffix = "╭──────┬──────╮│ 1000 │ 1001 ││ 1001 │ 1002 │╰──────┴──────╯";
let expected_suffix = actual.out.strip_suffix(suffix);
assert!(expected_suffix.is_some(), "{:?}", actual.out);
}
#[test]
fn table_index_offset() {
let actual = nu!(r#"1..1002 | table"#);
let suffix = "╭──────┬──────╮│ 1000 │ 1001 ││ 1001 │ 1002 │╰──────┴──────╯";
let expected_suffix = actual.out.strip_suffix(suffix);
assert!(expected_suffix.is_some(), "{:?}", actual.out);
}