Open madchicken opened 2 months ago
Hi @madchicken
Panics are bad...................................................
When a column text contains special chars, like \n or \t
\t
, \r
in particular will likely break things up in general.
see https://github.com/zhiburt/tabled/tree/master?tab=readme-ov-file#charset
So yes you may be right about the cause; But I guess it's shall be fixed somehow else then to account for it; if this is an actual issue.
But I am convinced we shall avoid panic, I'll take a look at your patch.
Thanks for bringing it up; And sorry for such an issue....
Have a good weekend.
I completely missed that part of the documentation, my bad. My PR is probably to close, but I wanted to give it a try. In general, it would be good to have a way to split headers predictably. In my case, for example, I have the name of a table and on the next line I am trying to display the name of the column (if present in my data)
In general, it would be good to have a way to split headers predictably. In my case, for example, I have the name of a table and on the next line I am trying to display the name of the column (if present in my data)
Could you give an example so I could help?
I think the example I attached to the issue should let you understand what I mean, where I know the header has a break line:
https://gist.github.com/madchicken/1dc891cd5192231729c0f750d84c2a65
but I think there is a bigger problem in the fact the code doesn't count "special" chars when trying to split lines in the wrap code (they are ignored since the returned size is always 0).
When a column text contains special chars, like \n or \t and the column is small enough, the current wrapping algorithm panic since in wrap.rs at line 309
line_with
>width
. To reproduce the bug, you use this code Please, run it in a small terminal (like 80-100 columns) otherwise you won't see the problem. I think the problem is in the way the width is calculated inside thesplit_at_width
function in utils/strings.rs