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

[IME] Can't input CompositionEnd only characters because of checking ccursor.index and ime_cursor.index #4486

Open
FrankLeeC opened this issue May 12, 2024 · 2 comments
Labels
bug Something is broken

Comments

@FrankLeeC
Copy link
Contributor

FrankLeeC commented May 12, 2024

Describe the bug
Sometimes can not type IME CompositionEnd characters.

To Reproduce
Use 'PinYin' input, type some words, then type in some other character such as 【 】 ……

Expected behavior
Type in any characters, including CompositionEnd characters.

Screenshots

IME-BUG.mp4

IME-BUG2

After typing !@, can not type any CompositionEnd character like 【】。,;

IME-BUG3
IME-BUG1

I'm using version 0.27.2, i see branch master has changed CompositionEnd to ImeEvent::Commit, but this bug still exists.
Here is why this happens.
/crates/egui/src/widgets/text_edit/builder.rs L974
if !prediction.is_empty() && cursor_range.secondary.ccursor.index == state.ime_cursor_range.secondary.ccursor.index
this prediction make sure cursor_range.secondary.ccursor.index equals state.ime_cursor_range.secondary.ccursor.index .
but when input CompositionEnd only characters after some other characters, cursor_range.secondary.ccursor.index is equals to the length of previous characters, and state.ime_cursor_range.secondary.ccursor.index equals to 0.

Below is my solution:
IME-BUGFIX2
IME-BUGFIX1

IME-BUGFIX.mp4

If we check this two cursors.index only when ime_state equals true which meanings we triggered CompositionStart first and currently continue typing some IME characters. if we trigger CompositionEnd first, there is no need to check cursor.index.

Actually, i don't know why need to check cursor_range.secondary.ccursor.index == state.ime_cursor_range.secondary.ccursor.index, can you tell me the reason. Thanks 😊

Desktop (please complete the following information):

  • OS: Windows11
@FrankLeeC FrankLeeC added the bug Something is broken label May 12, 2024
@rustbasic
Copy link
Contributor

In the Master version, everything has been modified normally.
It will be applied to all next versions.

cursor_range.secondary.ccursor.index == state.ime_cursor_range.secondary.ccursor.index
The reason for checking is because the characters you are typing may be copied somewhere else.

@FrankLeeC
Copy link
Contributor Author

In the Master version, everything has been modified normally.

It will be applied to all next versions.

cursor_range.secondary.ccursor.index == state.ime_cursor_range.secondary.ccursor.index

The reason for checking is because the characters you are typing may be copied somewhere else.

Thank you! I 'll test in next version 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

No branches or pull requests

2 participants