Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@gspencergoog
Copy link
Contributor

Description

Fixes the problem where deleting a composing string leaves the last character of the composing string in the text field.

Related Issues

Tests

  • None currently, since I'm not sure how to write an IME test. (still draft because of this).

@gspencergoog gspencergoog requested a review from cbracken October 29, 2021 01:53
@google-cla google-cla bot added the cla: yes label Oct 29, 2021
@gspencergoog gspencergoog marked this pull request as ready for review October 29, 2021 18:02
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline, but I think what we should do is change this code:

if (compose_length <= 0) {
return std::nullopt;
}

to be:

    if (compose_length < 0) {
      return std::nullopt;
    }

i.e. just change the <= to a <.

I think TextInputManager::GetString() (and by extension GetComposingString and GetResultString) should return nullopt only when calling them is non-sensical (i.e. when the IME is not active, when the IME context is invalid, or when the window handle is invalid; in all other cases, we should return the composing string.

After the last backspace though, the composing string is empty and we should return it as such.

In terms of testing, we could create a small struct of trampoline functions for the Win32 IMM API calls here, and for the tests mock them out. GetString is private, but GetComposingString and GetResultString are both public and don't make too many API calls.

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows] Problem deleting last composing character

2 participants