cessen / ropey

A utf8 text rope for manipulating and editing large texts.
MIT License
1.04k stars 46 forks source link

Fix panic when comparing ropes with chunks that do not align at char bounds #65

Closed pascalkuthe closed 2 years ago

pascalkuthe commented 2 years ago

During the development of helix-editor/helix#3890, @xJonathanLEI provided a test case that would cause a panic in ropey.

It turns out that PartialEq for RopeSlice indexes into a str using byte indices that might not be char bounds. The fix for this issue was to simply operate on byte slices directly. The very similar PartialOrd implementation has received the same treatment in the past but PartialEq seems to have been overlooked.

cessen commented 2 years ago

Awesome! Thanks for catching this.