mathlive
mathlive copied to clipboard
PlusMinus retains some kind of state
Description
After deleting a plusminus sign with backspace, some kind of state is retained that makes the next minus key back into a plusminus
Steps to Reproduce
- Open the Mathlive demo page, delete the current contents
- type "+-". observe the \pm.
- hit backspace (delete on mac)
- type "-"
Actual Behavior
\pm is inserted again
Expected Behavior
"-" should be inserted
Environment
Mathlive 0.98.6 on demo page macOs chrome and Safari, current versions.
This is not an issue specific to PlusMinus, but goes to how inline shortcuts are handled. I understand this interaction may be unexpected, but it's unclear how to improve it.
Currently, a buffer keeps tracks of the keys that have been typed and on each new key considers if an inline shortcut is applicable. That buffer gets resets in some cases, for example if the selection is change or if the cursor is moved. However, on backspace the buffer is not reset, but instead the last entry in the buffer is removed. This allows a mistype such as sinj
to be corrected by typing BACKSPACE
and h
. If the buffer were reset on backspace, in order to correct this mistype you would need to type backspace twice, then retype sinh
.
Every shortcut conversion could snapshot the state of the mathfield before conversion and set a one-keystroke-trap for backspace, and if backspace is pressed, it could restore that snapshot before processing the backspace.