Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@logiclrd
Copy link
Contributor

@logiclrd logiclrd commented Nov 15, 2025

This PR adds SingleActivator mappings for IBM CUA style clipboard accessors, with which Shift-Delete, Ctrl-Insert and Shift-Insert are equivalent to ^X ^C ^V. These mappings are natively supported on Windows and Linux (but not OS X).

Not sure what to do about:

  • Documentation: Are ^X ^C ^V already documented?
  • Tests: Are there existing tests for ^X ^C ^V already? Is it possible to mock out the clipboard so that a test of this functionality doesn't hit the actual system clipboard?
  • OS X: Is it a problem that, with this change, Flutter will accept these additional shortcuts even though they aren't a part of the platform paradigm?

UPDATE:
I'm not aware of existing documentation of clipboard shortcuts.

I have added tests, both of the existing ^X ^C ^V and of the IBM CUA style mappings added by this PR, and in the current iteration the changes do not add IBM CUA style mappings on OS X.

Fixes: #178483

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], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

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. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@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 Nov 15, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for IBM CUA style clipboard shortcuts (Shift+Delete for cut, Ctrl+Insert for copy, and Shift+Insert for paste) on non-Apple platforms. The implementation correctly adds these shortcuts to the common shortcuts map.

My review focuses on two main points: improving the clarity of an overridden shortcut and adding test coverage for the new functionality, both of which are guided by the repository's style guide. I've provided a detailed comment with a code suggestion to address these.

@github-actions github-actions bot added the a: tests "flutter test", flutter_test, or one of our tests label Nov 15, 2025
@logiclrd
Copy link
Contributor Author

Alright, this is now considerably more nuanced.

  • DefaultTextEditingShortcuts no longer maps Shift-Delete to the same action as Delete, but instead defines a block specifically for clipboard-related shortcuts _clipboardShortcuts and selectively includes it for Android, Linux and Windows. MacOS is excluded, which matches the previous behaviour because MacOS also excudes _commonShortcuts where ^X, ^C and ^V were previously defined.
  • The explicit exclusion of mappings for clipboard actions in _webDisablingTextShortcuts now dynamically generates its exclusions from _clipboardShortcuts rather than explicitly specifying ^X, ^C and ^V.
  • Automated testing includes tests of clipboard actions, limited to the target platform variants where they are defined. A simple fluent syntax is introduced to keep the definition of these target platform variant sets concise.

All tests pass.

Copy link
Contributor

@bleroux bleroux 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 this great contribution 🙏

Some minor nits and see my comment about the fluent API.

// Xerox/Apple: ^X ^C ^V
// -> Standard on Windows
// -> Standard on Linux
// -> Standard on OS X (with Command as modifier)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// -> Standard on OS X (with Command as modifier)
// -> Standard on macOS (with Command as modifier)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In context here, these aren't the enum TargetPlatform members. I did a quick search of the source code and found precedent elsewhere for a human-readable version being expressed as Mac OS X (change_mach_o_flags.py, util.dart under web_ui, ax_platform_node.h, etc.).

@bleroux bleroux requested a review from justinmc November 18, 2025 07:58
@github-actions github-actions bot removed the a: tests "flutter test", flutter_test, or one of our tests label Nov 18, 2025
@logiclrd
Copy link
Contributor Author

Hmm, what does this mean?:

image

I thought it had added the label because the changes intersected the test suite. They still do, but the label has been removed?

@bleroux
Copy link
Contributor

bleroux commented Nov 18, 2025

Hmm, what does this mean?:

The a: tests label applies when there are changes to the testing APIs. It was previously added because there were some changes to the widget_tester.dart file (the fluent API). As those changes are reverted the label is no more needed.

@bleroux
Copy link
Contributor

bleroux commented Nov 18, 2025

About the ci.yaml validation failure, usually rebasing the PR to the tip of the tree fixes it, can you try?

- Added SingleActivator mappings for Shift-Delete, Ctrl-Insert and Shift-Insert (equivalent to ^X ^C ^V).
- Added comment blocks explaining the provenance.
…delete the character forward in default_text_editing_shortcuts.dart.
- Moved the clipboard shortcuts into their own dedicated map _clipboardShortcuts.
- Updated _androidShortcuts, _linuxShortcuts and _windowsShortcuts to include _clipboardShortcuts.
- Updated _webDisablingTextShortcuts to generate disabling shortcuts dynamically for everything in _clipboardShortcuts, removing the explicit ^X, ^C and ^V.
… in widget_tester.dart to allow fluent syntax for configuring a specific set of target variants.

Updated clipboard shortcuts tests in default_text_editing_shortcuts_test.dart to target desktop except macOS, and android.
Updated ActionSpyState in default_text_editing_shortcuts_test.dart to capture the intent for CopySelectionTextIntent and PasteTextIntent.
… a SingleActivator line moved out of the pressShift loop.
…o match similar references elsewhere in the codebase.

Removed the fluent TargetPlatformVariant syntax and replaced its uses with explicit sets.
@logiclrd logiclrd force-pushed the classic-clipboard-key-combos branch from 61a9d6f to d3fb297 Compare November 18, 2025 19:48
Copy link
Member

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 18, 2025
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Dec 18, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Dec 18, 2025

autosubmit label was removed for flutter/flutter/178561, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 20, 2025
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Dec 20, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Dec 20, 2025

autosubmit label was removed for flutter/flutter/178561, because - The status or check suite Linux analyzer_benchmark has failed. Please fix the issues identified (or deflake) before re-applying this label.

@loic-sharma
Copy link
Member

@logiclrd It looks like there's a few lints you'll need to address before we can merge this in: https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8695004791188624433/+/u/run_test.dart_for_analyze_shard_and_subshard_None/stdout

Analyzing Flutter repository...                                    23.3s


   info • Omit the type annotation on a local variable when the type is obvious • packages/flutter/test/widgets/default_text_editing_shortcuts_test.dart:1133:13 • omit_obvious_local_variable_types
   info • Omit the type annotation on a local variable when the type is obvious • packages/flutter/test/widgets/default_text_editing_shortcuts_test.dart:1135:13 • omit_obvious_local_variable_types
   info • Omit the type annotation on a local variable when the type is obvious • packages/flutter/test/widgets/default_text_editing_shortcuts_test.dart:1178:13 • omit_obvious_local_variable_types
   info • Omit the type annotation on a local variable when the type is obvious • packages/flutter/test/widgets/default_text_editing_shortcuts_test.dart:1180:13 • omit_obvious_local_variable_types
4 issues found. (4 new) • analyzed 5423 files (ran in 23.31s)
Analysis benchmark written to analysis_benchmark.json ({time: 23.307, issues: 4}).

Copy link
Contributor

@justinmc justinmc 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 catching this. I'm always worried there are a few obscure keyboard shortcuts that Flutter is missing.

@justinmc justinmc added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 29, 2025
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Dec 29, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Dec 29, 2025

autosubmit label was removed for flutter/flutter/178561, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

@bleroux bleroux added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 29, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Dec 29, 2025
Merged via the queue into flutter:master with commit 8fe208e Dec 29, 2025
71 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Dec 29, 2025
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 framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TextInput: Shift-Insert does not work to paste

4 participants