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

Conversation

yeatse
Copy link
Contributor

@yeatse yeatse commented Jul 7, 2022

An emoji may consist of two or more characters. We should make sure that deleting backward should remove the entire emoji.

Fixes flutter/flutter#106933

This issue was introduced in #32223

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@yeatse
Copy link
Contributor Author

yeatse commented Jul 18, 2022

Kindly ping @jmagman for another look😀

@zanderso zanderso requested a review from jmagman July 21, 2022 15:32
options:kNilOptions
range:charRange
remainingRange:NULL];
if (gotCodePoint && u_hasBinaryProperty(codePoint, UCHAR_EMOJI)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this getting applied only to emoji?

Aren't there other multi-byte characters that are not emoji that we'd want to apply this to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From #34508 (comment), languages with diacritical marks will expect a backward deletion should only delete one part of the composed character, such as Thai and Hebrew.

We have two ways to distinguish this behavior from emoji's:

  1. check if the byte is a diacritical mark (and other properties I don't know yet)
  2. check if the byte is not in an emoji

I chose the second one to keep consistency with android (see FlutterTextUtils.getOffsetBefore)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahhh ok this makes sense.

@@ -7,6 +7,8 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#include "unicode/uchar.h"
Copy link
Member

Choose a reason for hiding this comment

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

@dnfield since you jumped in, how do you feel about including this library? I've been trying to think of another way to check if it's an emoji without importing this but also reinventing the wheel. I guess it's okay?

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems fine to me. This is what ICU is for and there's no getting around having ICU in a flutter app

Comment on lines +83 to +84
argument = "--icu-data-file-path=Frameworks/Flutter.framework/icudtl.dat"
isEnabled = "YES">
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed?

Copy link
Contributor Author

@yeatse yeatse Jul 23, 2022

Choose a reason for hiding this comment

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

Yes. Without this the test will fail due to failing to load the ICU data file. Maybe we should file another issue to get rid of this later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is fine - in other tests we use the command line argument to load the ICU data file (see run_tests.py).

Copy link
Member

@jmagman jmagman 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 for the contribution and adding the backfilled tests!

@jmagman
Copy link
Member

jmagman commented Jul 25, 2022

@dnfield can you give the second hacker review?

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

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

LGTM, as a hacker

cyanglaz pushed a commit to cyanglaz/engine that referenced this pull request Oct 17, 2022
godofredoc pushed a commit that referenced this pull request Oct 17, 2022
* Fix an issue that deleting an emoji may crash the app (#34508)

* Workaround iOS text input crash for emoji+Korean text (#36295)

Co-authored-by: Yang Chao <[email protected]>
Co-authored-by: Chris Yang <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-android platform-ios platform-linux
Projects
None yet
3 participants