AccessKit / accesskit

UI accessibility infrastructure across platforms and programming languages
BSD 3-Clause "New" or "Revised" License
991 stars 48 forks source link

fix: Clamp character indices when converting a text selection to a range #416

Closed mwcampbell closed 1 month ago

mwcampbell commented 1 month ago

@DataTriny discovered a way to cause a panic in AccessKit when moving in an egui multi-line edit. Apparently, the egui cursor can end up being outside the actual bounds of the text. I could fix this in egui, but I think it's better to make AccessKit resilient to broken implementations, when we can do so at little cost. So I implemented a fix in AccessKit instead.

To test this fix with egui, you'll need to cherry-pick this PR onto a local copy of the winit-0.29-backport branch.

DataTriny commented 1 month ago

For reference, here are the steps that would trigger a panic:

I can confirm that this PR fixes the bug.