desmosinc / mathquill

Magic textboxes where you can type math as easily as writing!
mathquill.com
137 stars 42 forks source link

Fix Shift-Tab and Shift-Escape with a selection #233

Closed jwmerrill closed 2 years ago

jwmerrill commented 2 years ago

Cursor.show has a special case for where to place the cursor DOM when there is something to the right of the cursor and there is a selection:

https://github.com/desmosinc/mathquill/blob/9606bd8a7a931a8902346793083f4c1093f49d01/src/cursor.ts#L80-L81

When escaping to the left out of a block with an active selection, the selection was previously not being cleared, which was causing the cursor DOM to get put in a place that was related to the previous selection instead of to where MQ's model of the cursor says it should be.

jwmerrill commented 2 years ago

It looks like that special case for where to put cursor DOM when there is a selection has been in MQ for a very long time: https://github.com/mathquill/mathquill/blame/c2c0badeec480920742efa87597ac50330954935/src/cursor.js#L26

But I'm having trouble reasoning about what the intent is. I tried making it so that branch is never taken, and MQs unit tests all still pass.