Skip to content

Commit

Permalink
Possible fix to format_tools
Browse files Browse the repository at this point in the history
  • Loading branch information
InAnYan committed Nov 11, 2024
1 parent 9000678 commit ea27a1f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions module/core/format_tools/src/format/output_format/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,19 @@ impl TableOutputFormat for Table
write!( c.buf, "{}", cell_prefix )?;

println!( "icol : {icol} | irow : {irow} | width : {width} | cell_width : {cell_width} | slice.len() : {}", slice.len() );
let lspaces = ( width - cell_width ) / 2;
let rspaces = ( width - cell_width + 1 ) / 2 + cell_width - slice.len();

let lspaces = if cell_width > width {
0
} else {
( width - cell_width ) / 2
};

let rspaces = if (cell_width > width) || (slice.len() > cell_width) {
0
} else {
( width - cell_width + 1 ) / 2 + cell_width - slice.len()
};

// println!( "icol : {icol} | irow : {irow} | width : {width} | cell_width : {cell_width} | lspaces : {lspaces} | rspaces : {rspaces}" );

if lspaces > 0
Expand Down

0 comments on commit ea27a1f

Please sign in to comment.