Fix some issues with table wrapping of lists (#7598)

close #7591 

I tend to think it must be addressed.
But I'd verify it @rgwood.

PS: I've noticed how `table -e` and `table` with the same width wraps a
bit differently sometimes. (I guess it also must be addressed......)

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
This commit is contained in:
Maxim Zhiburt
2022-12-25 03:27:34 +03:00
committed by GitHub
parent d8cde2ae89
commit b499e7c682
3 changed files with 25 additions and 11 deletions

View File

@ -450,7 +450,7 @@ fn truncate_columns_by_content(data: &mut Data, theme: &TableTheme, termwidth: u
}
// we don't need any truncation then (is it possible?)
if truncate_pos + 1 == data.count_columns() {
if truncate_pos == data.count_columns() {
return false;
}

View File

@ -1,4 +1,4 @@
use tabled::{builder::Builder, Padding, Style, Width};
use tabled::{builder::Builder, object::Cell, Modify, Padding, Style, Width};
pub fn string_width(text: &str) -> usize {
tabled::papergrid::util::string_width_multiline_tab(text, 4)
@ -16,9 +16,11 @@ pub fn wrap_string(text: &str, width: usize) -> String {
Builder::from_iter([[text]])
.build()
.with(Padding::zero())
.with(Style::empty())
.with(Width::wrap(width))
.with(Padding::zero())
.with(Modify::new(Cell(0, 0)).with(Width::wrap(width)))
.to_string()
.trim_end()
.to_string()
}