Skip to content

Commit

Permalink
Try to fix #7338 (#7343)
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Zhiburt <[email protected]>
  • Loading branch information
zhiburt committed Dec 4, 2022
1 parent 12deff5 commit 41178df
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions crates/nu-command/src/viewers/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,8 +912,6 @@ fn convert_to_table2<'a>(
}

for (row, item) in input.clone().into_iter().enumerate() {
let row = if with_header { row + 1 } else { row };

if let Some(ctrlc) = &ctrlc {
if ctrlc.load(Ordering::SeqCst) {
return Ok(None);
Expand All @@ -935,6 +933,8 @@ fn convert_to_table2<'a>(
column_width = max(column_width, width);

let value = NuTable::create_cell(value.0, value.1);

let row = if with_header { row + 1 } else { row };
data[row].push(value);
}

Expand Down
32 changes: 16 additions & 16 deletions crates/nu-command/tests/commands/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ fn table_expand_0() {
"╭───┬───┬───┬───────────╮\
│ # │ a │ b │ c │\
├───┼───┼───┼───────────┤\
1 │ 1 │ 2 │ 3 │\
2 │ 4 │ 5 │ ╭───┬───╮ │\
0 │ 1 │ 2 │ 3 │\
1 │ 4 │ 5 │ ╭───┬───╮ │\
│ │ │ │ │ 0 │ 1 │ │\
│ │ │ │ │ 1 │ 2 │ │\
│ │ │ │ │ 2 │ 3 │ │\
Expand All @@ -53,8 +53,8 @@ fn table_expand_exeed_overlap_0() {
"╭───┬────────────────────────┬───┬───────────╮\
│ # │ a │ b │ c │\
├───┼────────────────────────┼───┼───────────┤\
1 │ xxxxxxxxxxxxxxxxxxxxxx │ 2 │ 3 │\
2 │ 4 │ 5 │ ╭───┬───╮ │\
0 │ xxxxxxxxxxxxxxxxxxxxxx │ 2 │ 3 │\
1 │ 4 │ 5 │ ╭───┬───╮ │\
│ │ │ │ │ 0 │ 1 │ │\
│ │ │ │ │ 1 │ 2 │ │\
│ │ │ │ │ 2 │ 3 │ │\
Expand All @@ -73,8 +73,8 @@ fn table_expand_exeed_overlap_0() {
"╭──────┬───────────────────────────────────────────────────┬─────┬─────────────╮\
│ # │ a │ b │ c │\
├──────┼───────────────────────────────────────────────────┼─────┼─────────────┤\
1 │ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx │ 2 │ 3 │\
2 │ 4 │ 5 │ ╭───┬───╮ │\
0 │ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx │ 2 │ 3 │\
1 │ 4 │ 5 │ ╭───┬───╮ │\
│ │ │ │ │ 0 │ 1 │ │\
│ │ │ │ │ 1 │ 2 │ │\
│ │ │ │ │ 2 │ 3 │ │\
Expand All @@ -91,8 +91,8 @@ fn table_expand_deep_0() {
"╭───┬───┬───┬────────────────────────╮\
│ # │ a │ b │ c │\
├───┼───┼───┼────────────────────────┤\
1 │ 1 │ 2 │ 3 │\
2 │ 4 │ 5 │ ╭───┬────────────────╮ │\
0 │ 1 │ 2 │ 3 │\
1 │ 4 │ 5 │ ╭───┬────────────────╮ │\
│ │ │ │ │ 0 │ 1 │ │\
│ │ │ │ │ 1 │ 2 │ │\
│ │ │ │ │ 2 │ [list 3 items] │ │\
Expand All @@ -109,8 +109,8 @@ fn table_expand_deep_1() {
"╭───┬───┬───┬────────────────╮\
│ # │ a │ b │ c │\
├───┼───┼───┼────────────────┤\
1 │ 1 │ 2 │ 3 │\
2 │ 4 │ 5 │ [list 3 items] │\
0 │ 1 │ 2 │ 3 │\
1 │ 4 │ 5 │ [list 3 items] │\
╰───┴───┴───┴────────────────╯"
);
}
Expand All @@ -123,8 +123,8 @@ fn table_expand_flatten_0() {
"╭───┬───┬───┬───────────────╮\
│ # │ a │ b │ c │\
├───┼───┼───┼───────────────┤\
1 │ 1 │ 2 │ 3 │\
2 │ 4 │ 5 │ ╭───┬───────╮ │\
0 │ 1 │ 2 │ 3 │\
1 │ 4 │ 5 │ ╭───┬───────╮ │\
│ │ │ │ │ 0 │ 1 │ │\
│ │ │ │ │ 1 │ 2 │ │\
│ │ │ │ │ 2 │ 1 1 1 │ │\
Expand All @@ -143,8 +143,8 @@ fn table_expand_flatten_1() {
"╭───┬───┬───┬───────────────╮\
│ # │ a │ b │ c │\
├───┼───┼───┼───────────────┤\
1 │ 1 │ 2 │ 3 │\
2 │ 4 │ 5 │ ╭───┬───────╮ │\
0 │ 1 │ 2 │ 3 │\
1 │ 4 │ 5 │ ╭───┬───────╮ │\
│ │ │ │ │ 0 │ 1 │ │\
│ │ │ │ │ 1 │ 2 │ │\
│ │ │ │ │ 2 │ 1,1,1 │ │\
Expand All @@ -164,8 +164,8 @@ fn table_expand_flatten_and_deep_1() {
"╭───┬───┬───┬────────────────────────────────╮\
│ # │ a │ b │ c │\
├───┼───┼───┼────────────────────────────────┤\
1 │ 1 │ 2 │ 3 │\
2 │ 4 │ 5 │ ╭───┬────────────────────────╮ │\
0 │ 1 │ 2 │ 3 │\
1 │ 4 │ 5 │ ╭───┬────────────────────────╮ │\
│ │ │ │ │ 0 │ 1 │ │\
│ │ │ │ │ 1 │ 2 │ │\
│ │ │ │ │ 2 │ ╭───┬────────────────╮ │ │\
Expand Down

0 comments on commit 41178df

Please sign in to comment.