Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ghost delete event before insert event #357

Closed
radimitrov opened this issue Jan 17, 2023 · 3 comments
Closed

Ghost delete event before insert event #357

radimitrov opened this issue Jan 17, 2023 · 3 comments
Labels
enhancement Improvement for existing feature

Comments

@radimitrov
Copy link

A workaround for this is to set editor.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); so it is related to text composition. Maybe just in the editor events?
In this example I'm simply using Gboard to type. Haven't pressed the backspace key.

Test code:

        editor.subscribeEvent(ContentChangeEvent.class, (e, unsub) -> {
            if (e.getAction() == ContentChangeEvent.ACTION_DELETE) {
                Log.d("ContentChangeEvent", "delete");
            }
            else if (e.getAction() == ContentChangeEvent.ACTION_INSERT) {
                Log.d("ContentChangeEvent", "insert");
            }
            if (e.getAction() == ContentChangeEvent.ACTION_SET_NEW_TEXT) {
                Log.d("ContentChangeEvent", "newtext");
            }
        });

Output:

2023-01-17 11:53:08.171 19029-19029/com.example.soraeditortest D/ContentChangeEvent: insert
2023-01-17 11:53:19.503 19029-19029/com.example.soraeditortest D/ContentChangeEvent: insert
2023-01-17 11:53:19.618 19029-19029/com.example.soraeditortest D/ContentChangeEvent: delete
2023-01-17 11:53:19.627 19029-19029/com.example.soraeditortest D/ContentChangeEvent: insert
2023-01-17 11:53:19.796 19029-19029/com.example.soraeditortest D/ContentChangeEvent: delete
2023-01-17 11:53:19.805 19029-19029/com.example.soraeditortest D/ContentChangeEvent: insert
2023-01-17 11:53:19.923 19029-19029/com.example.soraeditortest D/ContentChangeEvent: delete
2023-01-17 11:53:19.933 19029-19029/com.example.soraeditortest D/ContentChangeEvent: insert
@Rosemoe
Copy link
Owner

Rosemoe commented Jan 17, 2023

According to ducumentation for InputConnection#setComposingText:

Replace the currently composing text with the given text, and set the new cursor position. Any composing text set previously will be removed automatically.

sora-editor deletes the composing text first and inserts the new one.

@Rosemoe
Copy link
Owner

Rosemoe commented Jan 17, 2023

This does can be avoided in some cases (by converting the operation to a single deletion or insertion).

@Rosemoe Rosemoe added the enhancement Improvement for existing feature label Jan 17, 2023
@radimitrov
Copy link
Author

Didn't know Android implements composition like that, but I guess it makes it simpler.
An easy workaround on the IDE side would be a single shot timer that checks is there was an insertion for example 20ms after a deletion.
Not exactly optimal, but it will get the job done when needed. However I don't think that is a good idea to be a "fix".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement for existing feature
Projects
None yet
Development

No branches or pull requests

2 participants