Skip to content

Update hasTrailingSpaces - #149698

Merged
auto-submit[bot] merged 9 commits into
flutter:masterfrom
ttorii20:fix/cursor-alignment-fullwidth-spaces
Jun 10, 2024
Merged

auto-submit[bot] merged 9 commits into
flutter:masterfrom
ttorii20:fix/cursor-alignment-fullwidth-spaces

Conversation

@ttorii20

@ttorii20 ttorii20 commented Jun 5, 2024 •

Copy link
Copy Markdown
Contributor

This PR addresses an issue with TextPainter's caret position calculation for text containing full-width spaces. Currently, the caret position is not accurately calculated for strings with full-width spaces. To resolve this, the following changes have been made:

Corrected the logic for caret position calculation when full-width spaces are present in the text.
Added and updated test cases to ensure accurate caret position calculation.
These changes ensure that the caret position for text with full-width spaces is computed correctly.

This issue was introduced by the commit a0a854a.

Related Issue: #149099

Pre-launch Checklist

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

@github-actions github-actions Bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. labels Jun 5, 2024
@ttorii20
ttorii20 marked this pull request as ready for review June 6, 2024 11:43
@justinmc
justinmc requested a review from LongCatIsLooong June 6, 2024 21:39

@LongCatIsLooong LongCatIsLooong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

The whole trailing space check thing is a hack and we should expose the width of a line with trailing spaces instead. But that will be a riskier fix to cherry-pick to the beta / stable channel (if you intend to do so).

@@ -356,6 +356,7 @@ class _TextLayout {
// last logical trailing space.

@LongCatIsLooong LongCatIsLooong Jun 7, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I looked at the SkParagraph code and it looks like the statement here about it treating only " " and "\t" as spaces is not true. It's using code unit properties. Could you update or delete that first paragraph?

final TextPainter painter = TextPainter()
..textDirection = TextDirection.ltr;

const String text = 'A ';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: could you use \u{3000} to make it more obvious (or add a comment) that there is a trailing fullwidth space after A?

painter.dispose();
});

test('TextPainter caret test with trailing full-width space', () {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: move this to the "caret" test group?

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍

But seconding the nits left by @LongCatIsLooong .

painter.dispose();
});


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Too many newlines here, there should only be one.

@ttorii20

ttorii20 commented Jun 8, 2024

Copy link
Copy Markdown
Contributor Author

Hi @LongCatIsLooong @justinmc

Thank you both for your review!

I have completed the requested changes:

  • Updated the SkParagraph white space handling comments.
  • Merged the trailing full-width space test into the existing caret test.
    Please review the latest commit.

@LongCatIsLooong LongCatIsLooong left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you delete the sentence that says "SkParagraph currently treats " ", "\t", and "\u{3000}" as white spaces."? (since it's still a bit misleading as SkParagraph treats a wider range of codepoints as spaces when doing line breaking).

@LongCatIsLooong

LongCatIsLooong commented Jun 8, 2024 •

Copy link
Copy Markdown
Contributor

Also if you would like to cherry-pick the commit (after the PR is merged), feel free to create a CP request using the automated workflow.

@LongCatIsLooong

Copy link
Copy Markdown
Contributor

LGTM thank you for the fix!

@LongCatIsLooong LongCatIsLooong added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 8, 2024
@ttorii20

ttorii20 commented Jun 8, 2024

Copy link
Copy Markdown
Contributor Author

LGTM thank you for the fix!

Thank you for the review!

@auto-submit

auto-submit Bot commented Jun 8, 2024

Copy link
Copy Markdown
Contributor

auto label is removed for flutter/flutter/149698, due to - The status or check suite Linux web_long_running_tests_1_5 has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 8, 2024
@LongCatIsLooong LongCatIsLooong added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 10, 2024
@auto-submit
auto-submit Bot merged commit 739e3bd into flutter:master Jun 10, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 11, 2024
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jun 11, 2024
flutter/flutter@32081aa...14df7be

2024-06-11 [email protected] Revert "Add tests for scaffold drawer and end drawer" (flutter/flutter#150045)
2024-06-11 [email protected] Add tests for scaffold drawer and end drawer (flutter/flutter#149383)
2024-06-11 [email protected] Add high-contrast theme (flutter/flutter#149779)
2024-06-11 [email protected] Manual Pub Roll (flutter/flutter#150025)
2024-06-10 [email protected] [docs] Per-platform desktop triage instructions (flutter/flutter#150019)
2024-06-10 [email protected] Fix copy-paste-o in MethodChannel.invokeListMethod doc (flutter/flutter#149976)
2024-06-10 [email protected] Unpin `camera_android` and remove its only usage (flutter/flutter#150017)
2024-06-10 [email protected] Fixes a bug where NavigatorState.pop does not consider any possible sâ�¦ (flutter/flutter#150014)
2024-06-10 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Reland: [CupertinoActionSheet] Match colors to native (#149568) (#150015)" (flutter/flutter#150021)
2024-06-10 [email protected] Reland: [CupertinoActionSheet] Match colors to native (#149568) (flutter/flutter#150015)
2024-06-10 [email protected] Temporarily run Mac_arm64 framework_tests_misc on only Mac-13 (flutter/flutter#150009)
2024-06-10 [email protected] Fixes TextField hinttext in a11y_assessment (flutter/flutter#150007)
2024-06-10 [email protected] Use const bool.fromEnvironment("dart.tool.dart2wasm") to detect dart2wasm (flutter/flutter#149996)
2024-06-10 [email protected] Roll Packages from 8a2c4e4 to e95fe4a (3 revisions) (flutter/flutter#149997)
2024-06-10 [email protected] [web] Notify engine of handled PointerScrollEvents. (flutter/flutter#145500)
2024-06-10 [email protected] Cut no-longer-accurate microtask reference in finalizeTree doc (flutter/flutter#149941)
2024-06-10 [email protected] Update hasTrailingSpaces (flutter/flutter#149698)
2024-06-10 [email protected] [web] Change `--web-renderer` default from `auto` to `canvaskit` (flutter/flutter#149773)
2024-06-10 [email protected] Retain the toString method for subclasses of Key in profile/release mode (flutter/flutter#149926)
2024-06-10 [email protected] Remove package:platform from issue template (flutter/flutter#149995)
2024-06-10 [email protected] Revert "[CupertinoActionSheet] Match colors to native (#149568)" (flutter/flutter#149998)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
yqritc pushed a commit to yqritc/flutter that referenced this pull request Jul 19, 2024
This PR addresses an issue with TextPainter's caret position calculation for text containing full-width spaces. Currently, the caret position is not accurately calculated for strings with full-width spaces. To resolve this, the following changes have been made:

Corrected the logic for caret position calculation when full-width spaces are present in the text.
Added and updated test cases to ensure accurate caret position calculation.
These changes ensure that the caret position for text with full-width spaces is computed correctly.

This issue was introduced by the commit [a0a854a](flutter@a0a854a).

Related Issue: [flutter#149099](flutter#149099)
auto-submit Bot pushed a commit that referenced this pull request Jul 26, 2024
…152215)

Changed the cursor position to be the same as before flutter 3.22.0 when 17 character codes in the Unicode Zs category are entered into a TextField.

Extend the support for #149698. As a result, #149099 is resolved.

The code for the Unicode-Zs category is based on the following page.
https://www.compart.com/en/unicode/category/Zs

Fixes #149099
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 6, 2024
TytaniumDev pushed a commit to TytaniumDev/flutter that referenced this pull request Aug 7, 2024
…lutter#152215)

Changed the cursor position to be the same as before flutter 3.22.0 when 17 character codes in the Unicode Zs category are entered into a TextField.

Extend the support for flutter#149698. As a result, flutter#149099 is resolved.

The code for the Unicode-Zs category is based on the following page.
https://www.compart.com/en/unicode/category/Zs

Fixes flutter#149099
Buchimi pushed a commit to Buchimi/flutter that referenced this pull request Sep 2, 2024
…lutter#152215)

Changed the cursor position to be the same as before flutter 3.22.0 when 17 character codes in the Unicode Zs category are entered into a TextField.

Extend the support for flutter#149698. As a result, flutter#149099 is resolved.

The code for the Unicode-Zs category is based on the following page.
https://www.compart.com/en/unicode/category/Zs

Fixes flutter#149099
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
flutter/flutter@32081aa...14df7be

2024-06-11 [email protected] Revert "Add tests for scaffold drawer and end drawer" (flutter/flutter#150045)
2024-06-11 [email protected] Add tests for scaffold drawer and end drawer (flutter/flutter#149383)
2024-06-11 [email protected] Add high-contrast theme (flutter/flutter#149779)
2024-06-11 [email protected] Manual Pub Roll (flutter/flutter#150025)
2024-06-10 [email protected] [docs] Per-platform desktop triage instructions (flutter/flutter#150019)
2024-06-10 [email protected] Fix copy-paste-o in MethodChannel.invokeListMethod doc (flutter/flutter#149976)
2024-06-10 [email protected] Unpin `camera_android` and remove its only usage (flutter/flutter#150017)
2024-06-10 [email protected] Fixes a bug where NavigatorState.pop does not consider any possible sâ�¦ (flutter/flutter#150014)
2024-06-10 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Reland: [CupertinoActionSheet] Match colors to native (#149568) (#150015)" (flutter/flutter#150021)
2024-06-10 [email protected] Reland: [CupertinoActionSheet] Match colors to native (#149568) (flutter/flutter#150015)
2024-06-10 [email protected] Temporarily run Mac_arm64 framework_tests_misc on only Mac-13 (flutter/flutter#150009)
2024-06-10 [email protected] Fixes TextField hinttext in a11y_assessment (flutter/flutter#150007)
2024-06-10 [email protected] Use const bool.fromEnvironment("dart.tool.dart2wasm") to detect dart2wasm (flutter/flutter#149996)
2024-06-10 [email protected] Roll Packages from 8a2c4e4 to e95fe4a (3 revisions) (flutter/flutter#149997)
2024-06-10 [email protected] [web] Notify engine of handled PointerScrollEvents. (flutter/flutter#145500)
2024-06-10 [email protected] Cut no-longer-accurate microtask reference in finalizeTree doc (flutter/flutter#149941)
2024-06-10 [email protected] Update hasTrailingSpaces (flutter/flutter#149698)
2024-06-10 [email protected] [web] Change `--web-renderer` default from `auto` to `canvaskit` (flutter/flutter#149773)
2024-06-10 [email protected] Retain the toString method for subclasses of Key in profile/release mode (flutter/flutter#149926)
2024-06-10 [email protected] Remove package:platform from issue template (flutter/flutter#149995)
2024-06-10 [email protected] Revert "[CupertinoActionSheet] Match colors to native (#149568)" (flutter/flutter#149998)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
bisor0627 pushed a commit to bisor0627/packages that referenced this pull request Jun 19, 2026
flutter/flutter@32081aa...14df7be

2024-06-11 [email protected] Revert "Add tests for scaffold drawer and end drawer" (flutter/flutter#150045)
2024-06-11 [email protected] Add tests for scaffold drawer and end drawer (flutter/flutter#149383)
2024-06-11 [email protected] Add high-contrast theme (flutter/flutter#149779)
2024-06-11 [email protected] Manual Pub Roll (flutter/flutter#150025)
2024-06-10 [email protected] [docs] Per-platform desktop triage instructions (flutter/flutter#150019)
2024-06-10 [email protected] Fix copy-paste-o in MethodChannel.invokeListMethod doc (flutter/flutter#149976)
2024-06-10 [email protected] Unpin `camera_android` and remove its only usage (flutter/flutter#150017)
2024-06-10 [email protected] Fixes a bug where NavigatorState.pop does not consider any possible sâ�¦ (flutter/flutter#150014)
2024-06-10 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Reland: [CupertinoActionSheet] Match colors to native (#149568) (#150015)" (flutter/flutter#150021)
2024-06-10 [email protected] Reland: [CupertinoActionSheet] Match colors to native (#149568) (flutter/flutter#150015)
2024-06-10 [email protected] Temporarily run Mac_arm64 framework_tests_misc on only Mac-13 (flutter/flutter#150009)
2024-06-10 [email protected] Fixes TextField hinttext in a11y_assessment (flutter/flutter#150007)
2024-06-10 [email protected] Use const bool.fromEnvironment("dart.tool.dart2wasm") to detect dart2wasm (flutter/flutter#149996)
2024-06-10 [email protected] Roll Packages from 60e9e81 to 9e464d0 (3 revisions) (flutter/flutter#149997)
2024-06-10 [email protected] [web] Notify engine of handled PointerScrollEvents. (flutter/flutter#145500)
2024-06-10 [email protected] Cut no-longer-accurate microtask reference in finalizeTree doc (flutter/flutter#149941)
2024-06-10 [email protected] Update hasTrailingSpaces (flutter/flutter#149698)
2024-06-10 [email protected] [web] Change `--web-renderer` default from `auto` to `canvaskit` (flutter/flutter#149773)
2024-06-10 [email protected] Retain the toString method for subclasses of Key in profile/release mode (flutter/flutter#149926)
2024-06-10 [email protected] Remove package:platform from issue template (flutter/flutter#149995)
2024-06-10 [email protected] Revert "[CupertinoActionSheet] Match colors to native (#149568)" (flutter/flutter#149998)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems autosubmit Merge PR when tree becomes green via auto submit App framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants