Skip to content

Conversation

@canastro
Copy link
Contributor

@canastro canastro commented Apr 7, 2021

This PR focuses on supporting modifiers to delete blocks of text in a editable widget.

Shortcuts per OS

  • macOS
    • CMD (⌘) + Backspace: Delete all words left to the cursor
    • Option + Backspace: Delete word left to the cursor
  • Non macOS
    • Alt + Backspace: Delete all words left to the cursor
    • Ctrl + Backspace: Delete word left to the cursor

Some cases for reference:

case: 'text with| multiple words'
word modifier + backspace: 'text | multiple words'
line modifier + backspace: '| multiple words'
word modifier + delete: 'text with| words'
line modifier + delete: 'text with|'

case: 'text with multiple\n|words'
word modifier + backspace: 'text with |words'
line modifier + backspace: 'text with multiple\n|words'
word modifier + delete: 'text with multiple\n|'
line modifier + delete: 'text with multiple\n|'

case: 'text with multiple|\nwords'
word modifier + backspace: 'text with |\nwords'
line modifier + backspace: '|\nwords'
word modifier + delete: 'text with multiple|'
line modifier + delete: 'text with multiple|\nwords'

case: 'text with\n|\nmultiple words' in obscure text
word modifier + backspace: '|\nmultiple words'
line modifier + backspace: '|\nmultiple words'
word modifier + delete: 'text with\n|'
line modifier + delete: 'text with\n|'

case: 用多個塊測試 (cursor at offset 4)
backspace: '用多個測試' (cursor at offset 3)
word modifier + backspace: '用多個測試' (cursor at offset 3)
line modifier + backspace: '測試' (cursor at offset 0)
word modifier + delete: '用多個塊試' (cursor at offset 4)
line modifier + delete: '用多個塊' (cursor at offset 4)

case: برنامج أهلا بالعالم (cursor at offset 4 - from the right)
backspace: برنمج أهلا بالعالم (cursor at offset 3 - from the right)
word modifier + backspace: مج أهلا بالعالم (cursor at offset 0 - from the right)
word modifier + delete: برنا أهلا بالعالم (cursor at offset 4 - from the right)

Related issue:

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 feature I am adding, or Hixie said the PR is test-exempt.
  • All existing and new tests are passing.

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

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Apr 7, 2021
@google-cla google-cla bot added the cla: yes label Apr 7, 2021
@canastro
Copy link
Contributor Author

canastro commented Apr 7, 2021

@LongCatIsLooong @jmagman

Here is the commit that fixes the last merge attempt of this fix: 9b6c443
This was probably a test that was updated between my last rebase and the PR being merged.

Sorry for the inconvenient.

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 👍

I'll try to remember to keep an eye out for any new tests being added to editable_test.dart. I'll also try to be quick about merging this so that there is a low chance of more problems.

For the record, the test that caused the previous PR to fail was added in #79877.

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

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete by word does not work [macOS] Textfields should support CMD (⌘) + Backspace and Control + Backspace

2 participants