Repository navigation
Incorrect selection move by word with Chinese script #106472
Copy link
Copy link
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: desktopRunning on desktopRunning on desktopa: internationalizationSupporting other languages or locales. (aka i18n)Supporting other languages or locales. (aka i18n)a: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsfound in release: 3.0Found to occur in 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1Found to occur in 3.1frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packages
Description
Steps to Reproduce
- Execute
flutter runon the code sample - Copy and paste Chinese text
- Move to the beginning of the text
- Move the selection right by word (e.g. Ctrl + right arrow) twice, then left twice, then keep repeating
Expected results: Text selection goes back to the beginning
Actual results: Text selection keeps moving to the right
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(primarySwatch: Colors.blue),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(widget.title)),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
Text('Type stuff below'),
Expanded(
child: TextField(maxLines: null),
),
],
),
),
);
}
}Logs
> flutter doctor -v
[√] Flutter (Channel master, 3.1.0-0.0.pre.1354, on Microsoft Windows [Version 10.0.19044.1708], locale en-US)
• Flutter version 3.1.0-0.0.pre.1354 on channel master at C:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision a30012b275 (9 hours ago), 2022-06-22 17:04:07 -0700
• Engine revision fc08bf45b0
• Dart version 2.18.0 (build 2.18.0-216.0.dev)
• DevTools version 2.14.0
[X] Android toolchain - develop for Android devices
X Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.15)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.11.32510.428
• Windows 10 SDK version 10.0.19041.0
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
[√] VS Code, 64-bit edition (version 1.68.1)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.42.0
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.1708]
• Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.115
• Edge (web) • edge • web-javascript • Microsoft Edge 101.0.1210.39
[√] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 2 categories.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: desktopRunning on desktopRunning on desktopa: internationalizationSupporting other languages or locales. (aka i18n)Supporting other languages or locales. (aka i18n)a: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsfound in release: 3.0Found to occur in 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1Found to occur in 3.1frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packages

Activity
huycozy commentedon Jun 24, 2022
Hi @tgucio, thanks for filing the issue.
This issue is reproducible on the latest
stableandmasterchannels.When using
Ctrl + right arrow, the cursor position is moved wrong, it always moves forward.Demo
bandicam.2022-06-24.15-29-42-379.mp4
Sample code
flutter doctor -v
[√] Flutter (Channel stable, 3.0.3, on Microsoft Windows [Version 10.0.19043.1766], locale en-US) • Flutter version 3.0.3 at C:\WIP\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 676cefaaff (2 days ago), 2022-06-22 11:34:49 -0700 • Engine revision ffe7b86a1e • Dart version 2.17.5 • DevTools version 2.12.2 Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0) • Android SDK at C:\AndroidSDK • Platform android-32, build-tools 32.0.0 • ANDROID_HOME = C:\AndroidSDK • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.6) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.1.32421.90 • Windows 10 SDK version 10.0.20348.0 [√] Android Studio (version 2021.2) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840) [√] VS Code (version 1.68.1) • VS Code at C:\Users\ADMIN\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.42.0 [√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19043.1766] • Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.115 • Edge (web) • edge • web-javascript • Microsoft Edge 101.0.1210.53 [√] HTTP Host Availability • All required HTTP hosts are available • No issues found![√] Flutter (Channel master, 3.1.0-0.0.pre.1360, on Microsoft Windows [Version 10.0.19043.1766], locale en-US) • Flutter version 3.1.0-0.0.pre.1360 on channel master at C:\WIP\flutter_master • Upstream repository https://github.com/flutter/flutter.git • Framework revision 6c3a0e4d21 (4 hours ago), 2022-06-24 00:19:06 -0400 • Engine revision fc08bf45b0 • Dart version 2.18.0 (build 2.18.0-216.0.dev) • DevTools version 2.14.0 Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0) • Android SDK at C:\AndroidSDK • Platform android-32, build-tools 32.0.0 • ANDROID_HOME = C:\AndroidSDK • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.6) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.1.32421.90 • Windows 10 SDK version 10.0.20348.0 [√] Android Studio (version 2021.2) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840) [√] VS Code (version 1.68.1) • VS Code at C:\Users\ADMIN\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.42.0 [√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19043.1766] • Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.115 • Edge (web) • edge • web-javascript • Microsoft Edge 101.0.1210.53 [√] HTTP Host Availability • All required HTTP hosts are available • No issues found!tgucio commentedon Jun 24, 2022
Thanks for confirming @huycozy. BTW, I believe this isn't specific to windows but will behave the same on every platform (including mobile) using a HW keyboard.
huycozy commentedon Jun 28, 2022
@tgucio Thank you for reminding me, I can reproduce this issue on other desktop platforms. But it works well on Web.
Providing demo video as below:
✅: No Issue ❌: Issue reproduced
Demo
macos.mp4
web.mp4
linux.mp4
gspencergoog commentedon Jun 30, 2022
cc @justinmc
justinmc commentedon Jan 20, 2023
This appears fixed to me, can anyone else reproduce it on master still? It moves one character at a time now:
Screencast.from.2023-01-20.15-48-00.webm
Actually though, if I try it on gedit on Linux, it moves until it reaches punctuation. Maybe we should match that behavior.
Screencast.from.2023-01-20.15-49-10.webm
@Renzo-Olivares Do you have any thoughts on this since you have been working on boundary related stuff?
gnprice commentedon Mar 12, 2023
I don't reproduce the issue either. I think it would make sense to close it, and use a new issue for further improvements.
I think that behavior isn't great — it's moving past entire long clauses. But it might be better than moving a character at a time, given that if you want a character at a time you can always use plain left/right without Ctrl.
The ideal behavior would be to segment the text into words and move a word at a time. This is typically 2-3 characters, but can be less or more. To make it easy for everyone to reproduce the same details, here's some copy-pasteable text (from a Wikipedia article):
In that first sentence, if I use Ctrl+right/left in a browser's text input (in Chrome on Linux), the pieces it moves past are:
1894
年
,
孫文
成立
興中會
。
Each of those is a meaningful word or name (except the two that are pieces of punctuation.)
Doing that well requires a nontrivial language model, which I imagine is why gedit hasn't done it. I don't know if SkParagraph or another subsystem we already use might be equipped to do that for us.
justinmc commentedon Mar 20, 2023
Thanks for the investigation, I've opened #123065 to track. I'll go ahead and close this one.
github-actions commentedon Apr 3, 2023
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.