Repository navigation
Fix cursor jumping when doing character replacement - #1522
Conversation
srjfoo
left a comment
There was a problem hiding this comment.
Works for me.
P2 project Special Character Test Project with music has 4 astral plane characters at the end of the project custom chars.
|
This looks fine to me, but I don't see any behavior change. Based on the forum, it seems the issue is with the |
It's not unique to '𝑓', it's that generally the
Maybe, what the heck does |
:D And to my first point, I am not sure what change in this PR fixes the issue with |
The test project I mentioned above has some characters in it (at the end of the custom chars) that are from non-BMP characters. If you open a page in the main test sandbox (i.e. not the link above, but the same project in a regular TEST sandbox) and insert one or more of those characters and try deleting a regular character, the cursor should jump by the number non-BMP characters that you inserted. This doesn't happen in Casey's sandbox. |
I see now. I knew the behavior from the forum, but wasn't sure how @cpeel's change resolved it. I just played with it in the debugger to confirm. Essentially the fix is to not adjust the end on characters that are not in the map and let the browser take care of it. I like that solution. I think then my recommendation is one more small change to avoid manually storing the |
The JS to detect and automatically replace characters that aren't allowed on the site needs to adjust the cursor based on the grapheme length, not the JS internal UTF-16 string length.
9e5b66b to
9732a68
Compare
Perfect, thank you very much for that, it was very helpful! I've made the smallest surgical fix with this new knowledge which appears to resolve the issue. |
I don't remember writing any of this. git blame thinks @chrismiceli wrote it. |
70ray
left a comment
There was a problem hiding this comment.
Fixes odd behaviour around 𝑓
It was me! Look at that. |
The JS to detect and automatically replace characters that aren't allowed on the site needs to adjust the cursor based on the grapheme length, not the JS internal UTF-16 string length. This solves this issue reported in the forums.
I'm going to rely on @chrismiceli to tell me if there's a better way to solve this 😁
Sandbox: https://www.pgdp.org/~cpeel/c.branch/fix-text-processsor-jumping/