codemirror / dev

Development repository for the CodeMirror editor project
https://codemirror.net/
Other
5.84k stars 371 forks source link

Replacing a selection that ends at the start of a line places the new character in wrong place #929

Closed commandblockguy closed 2 years ago

commandblockguy commented 2 years ago

Describe the issue

Typing a character to replace the contents of the current selection when the current selection ends at the start of the line causes the newly typed character to appear at the wrong position.

For example, try placing the cursor before the g in the linked reproduction sandbox, then pressing shift+left to select the newline character. Then, press the b key. You're left with a single line containing bug, instead of the expected ubg.

Browser and platform

Firefox 103.0.2

Reproduction link

https://codemirror.net/try/?c=aW1wb3J0IHttaW5pbWFsU2V0dXAsIEVkaXRvclZpZXd9IGZyb20gImNvZGVtaXJyb3IiCgpuZXcgRWRpdG9yVmlldyh7CiAgZG9jOiAidVxuZyIsCiAgZXh0ZW5zaW9uczogbWluaW1hbFNldHVwLAogIHBhcmVudDogZG9jdW1lbnQuYm9keQp9KQo=

marijnh commented 2 years ago

This is caused by a Firefox bug, but attached patch should address this and similar issues.