Skip to content

fix: Remove assert_eq! from BiDi ShapeLine for avoid crash#508

Open
NSTikhomirov wants to merge 3 commits into
pop-os:mainfrom
NSTikhomirov:main
Open

fix: Remove assert_eq! from BiDi ShapeLine for avoid crash#508
NSTikhomirov wants to merge 3 commits into
pop-os:mainfrom
NSTikhomirov:main

Conversation

@NSTikhomirov

@NSTikhomirov NSTikhomirov commented May 30, 2026

Copy link
Copy Markdown

Cosmic-text can crash when certain characters show up in the editor view.

Error message:

thread 'main' panicked at /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/cosmic-text-0.19.0/src/shape.rs:1359:13:
assertion `left == right` failed
  left: false
 right: true

Reproduce steps (commit c24886c2471e5606587c46090cd25dbbf209186b):

printf 'A\034\327\220\n' > /tmp/bidi.txt
./editor-test.sh /tmp/bidi.txt

As I understand it, the assert expects all paragraphs in a line to have the same direction.
But for arbitrary text that's not always true, a line can split into paragraphs with different directions, and then it crashes on normal input.

And it seems this direction isn't really needed for correctness: the character order comes from the BiDi levels themselves, while the line direction is more for alignment and the ellipsis.
So I just removed the assert and shape the line by its base direction. No more panic, and normal lines look the same as before.

  • I have disclosed use of any AI generated code in my commit messages.
    • If you are using an LLM, and do not fully understand the changes it is making to the code base, do not create a PR.
    • In our experience, AI generated code often results in overly complex code that lacks enough context for a proper fix or feature inclusion. This results in considerably longer code reviews. Due to this, AI authored or partially authored PRs may be closed without comment.
  • I understand these changes in full and will be able to respond to review comments.
  • My change is accurately described in the commit message.
  • My contribution is tested and working as described.
  • I have read the Developer Certificate of Origin and certify my contribution under its conditions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant