Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Selection autocorrect suggestion from keyboard results in extra space character & misaligned cursor #1108

Open
bfollington opened this issue Feb 7, 2024 · 0 comments
Labels
Bug Something isn't working

Comments

@bfollington
Copy link
Collaborator

Repoted by a beta user. As the title says, tapping an autocorrect suggestion seemed to insert a space mid-word and left the cursor off-by-one from the end of the word.

Might be an intermittent issue, need to test to confirm.

image

@bfollington bfollington added the Bug Something isn't working label Feb 7, 2024
bfollington added a commit that referenced this issue Feb 14, 2024
While investigating
#1108 I
profiled the `plainEditor()` and found it was extremely expensive on
each keystroke. It's incredibly expensive to set the `.text` property on
the underlying view and doing so can result in cursor desync.

I suspect this is also responsible for
#566.

Setting `.text` frequently causes `updateUIView()` to take a LONG time
(up to 400ms in debug mode) which means `isUIViewUpdating` stays true
for a long time and we start dropping input events if the user is typing
rapidly. This is what is responsible for the autocorrect cursor desync
issue linked above and can be replicated by typing very fast into the
simulator. It's harder to trigger in release, on-device, but it happens
there too.

In brief: there's a pathological update cycle happening that results in
setting `.text` twice when we can set it 0 times. I've documented the
specifics in the code.

I made two changes:

1. enhance the change detection logic so we can trust `view.text` more
often instead of resetting it
1. split the rendering of the new gradient BG into another layer from
the editor itself (minor, but helpful)

The difference is more exaggerated on simulator, but it's night and day.

# Before


https://github.com/subconsciousnetwork/subconscious/assets/5009316/1eec6b50-8abf-4ddb-ab9e-ce0504597587

# After



https://github.com/subconsciousnetwork/subconscious/assets/5009316/39af615e-3802-48da-82a0-af04265b8df2
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant