conclave-team / conclave

CRDT and WebRTC based real-time, peer-to-peer, collaborative text editor
http://conclave.tech
MIT License
710 stars 130 forks source link

fix new line deletion bug in Chrome and Firefox #12

Closed sunny-b closed 6 years ago

sunny-b commented 6 years ago

I was sometimes getting an console error whenever I would try to delete a new-line character. I narrowed it down to a line of code in the CRDT class in the handleLocalDelete method. The method would try to remove characters from a line even if there were no characters on that line. I added a guard clause to handle the error.

I also realized the logic on the handleLocalDelete method was pretty complicated so I refactored it into several smaller methods so that it's easier to read.

closes #5