-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Fix Korean IME on Android #18030
Fix Korean IME on Android #18030
Conversation
You can test this PR using the following package version. |
SurroundingText always represents the current part of the text being edited, usually the current line. Removing the synchronization makes it impossible to update the position of the edit context. Just select a new line, and it should break. We need a way to detect that the SurroundingText isn't different from the buffer that the current InputConnection is aware of. SurroundingText is required to be able to virtualize the text buffer. We need to find a solution that makes this possible. Maybe we can sync the SurroundingText when the user explicitly changes the selection or a new line is selected. We might also need to use absolute indices to be able to determine the current SurroundingText is at a different position within the text buffer.
We could also try to compare the current text edit buffer with the new SurroundingText. And if they match we ignore that change. |
qemu-system-x86_64_0czKeYCk3z.mp4
Do you mean like this where I move the caret to a different line with arrow keys? I switched to master and the bug is present there too. In case you had something else in mind, what about adding The flag is set here public bool EndBatchEdit()
{
_batchLevel = Interlocked.Decrement(ref _batchLevel);
if (!IsInBatchEdit)
{
IsInUpdate = true;
while (_commandQueue.TryDequeue(out var command))
{
command.Apply(_editBuffer);
}
IsInUpdate = false;
}
UpdateState();
return IsInBatchEdit;
} meaning just around the code that gives rise to the unwanted |
Yes, that is what I meant. If that is still working there is no regression and we can keep the change as is. |
No, it's broken both in master and in this PR - the |
Y changes to SurroundingText should not affect the text buffer if it is being edited. The buffer already has all the information. Changes to SurroundingText are also propagated when the text is changed externally. In that case, the current text buffer should be reset. |
Then I think the condition is the only required change. Gboard and SwiftKey both work for Korean now. I don't suppose there's an integration test suite for Android text input? This all seems very prone to subtle bugs and regressions. |
You can test this PR using the following package version. |
We need proper automation infrastructure to be able to have integration tests |
You can test this PR using the following package version. |
Does it also help for Japanese? If probably yes there are some recent issues where we can ask the OP to test this PR |
Yeah, I have already posted a comment in that thread. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thank you
What does the pull request do?
Fixes #16956 on Android.
What is the current behavior?
AndroidInputMethod
subscribes toTextInputMethodClient
'sSurroundingTextChanged
, which ends up callingAvaloniaInputConnection.UpdateState
several times on each key press.AvaloniaInputConnection
also calls this method internally as part of its implementation of Android'sIInputConnection
, just after raising the previously mentionedSurroundingTextChanged
.I am not exactly sure what the relationship between
AndroidInputMethod
andAvaloniaInputConnection
is, but this behavior does not seem right. TheseUpdateState
calls are interfering with one another, messing up composition state when typing Korean. As soon as a 2-letter block is created,FinishComposingText
is called by the OS, making it impossible to create 3- and 4-letter blocks.What is the updated/expected behavior with this PR?
FinishComposingText
is not called when typing Korean. The user can keep typing without breaking composition, ultimately being able to create any syllable block. Deletes also work as expected - only the final letter part is removed, not the entire block.qemu-system-x86_64_VNePyHcDnI.mp4
How was the solution implemented (if it's not obvious)?
AndroidInputMethod
does not react toSurroundingTextChanged
, lettingAvaloniaInputConnection
handle its state. No idea whether anything else breaks as a result though.Checklist
Breaking changes
Don't know.