New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
panicked in Line::truncated
method due to byte index not being a char boundary
#1032
Comments
I suspect this might break many situations with emojis and not just in the table. |
Minimal repro: #[test]
fn truncation_works_with_emoji() {
let line = Line::raw( "123456789🦀");
let mut buf = Buffer::empty(Rect::new(0, 0, 10, 1));
line.render(buf.area, &mut buf);
assert_buffer_eq!(buf, Buffer::with_lines(vec!["123456789 "]));
} |
Hi there, I notice this as well in table columns that are truncated because the terminal is resized so they overflow. The line that is drawn in the truncated table column is cut at byte positions. In our app we draw a progress bar using unicode block characters in the upper right corner. We can reproduce easily by resizing our terminal to a smaller size, so the column widget cuts into the progress bar. Please confirm if this is a bug to be solved in ratatui. We use Crossterm 0.27.0 as backend on Linux / X11. |
is it here?
|
Should one iterate over chars() constructed from span.content?
This compiles, I think it is what is needed. |
Yes, it's a bug - feel free to submit a PR to fix and we can get a quick release out to fix it.
Yes likely. Can you make sure to add some unit tests with the PR. |
Hi, is
equivalent to
? e.g. it could all be off by one or something (is skip (n) same as indexing [n..] )? Cheers |
The slice type is independent from this project and a Rust type commonly used. Its basically |
I apologize for panics caused by my PR |
It's all good. Unicode is hard. No one gets it right the first time they have to deal with it. |
The right padding border symbols I added might caused a crash when resizing the terminal, which is an upstream bug: ratatui-org/ratatui#1032
This has 3 bugs still I think in the rendering, but these are not panics. Fixes ratatui-org#1032
- Rewrote the line / span rendering code to take into account how multi-byte / wide emoji characters are truncated when rendering into areas that cannot accommodate them in the available space - Added comprehensive coverage over the edge cases - Adds a benchmark to ensure perf Fixes: #1032 Co-authored-by: EdJoPaTo <rfc-conform-git-commit-email@funny-long-domain-label-everyone-hates-as-it-is-too-long.edjopato.de> Co-authored-by: EdJoPaTo <github@edjopato.de>
- Rewrote the line / span rendering code to take into account how multi-byte / wide emoji characters are truncated when rendering into areas that cannot accommodate them in the available space - Added comprehensive coverage over the edge cases - Adds a benchmark to ensure perf Fixes: ratatui-org#1032 Co-authored-by: EdJoPaTo <rfc-conform-git-commit-email@funny-long-domain-label-everyone-hates-as-it-is-too-long.edjopato.de> Co-authored-by: EdJoPaTo <github@edjopato.de>
ratatui fixed [unicode truncation bug](ratatui-org/ratatui#1032) in ratatui-org/ratatui#1089
Description
panic occured at
ratatui-0.26.2/src/text/line.rs:477:59
byte index 51 is not a char boundary; it is inside 'で' (bytes 49..52) of
🦀 RFC8628 OAuth 2.0 Device Authorization GrantでCLIからGithubのaccess tokenを取得する
at https://github.com/ymgyt/syndicationd/blob/a70475ec3a3dc284b1a209ace81bd29dcaaee00d/crates/synd_term/src/ui/components/subscription.rs#L314
To Reproduce
Expected behavior
does not panic
Screenshots
Environment
Additional context
The text was updated successfully, but these errors were encountered: