Skip to content

Implement delete by word - #77549

Closed
knopp wants to merge 4 commits into
flutter:masterfrom
knopp:delete_by_word
Closed

knopp wants to merge 4 commits into
flutter:masterfrom
knopp:delete_by_word

Conversation

@knopp

@knopp knopp commented Mar 8, 2021 •

Copy link
Copy Markdown
Member

#77547

Implements delete by word for RenderEditable

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 Mar 8, 2021
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

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.

@google-cla google-cla Bot added the cla: yes label Mar 8, 2021
@knopp
knopp requested review from justinmc and stuartmorgan-g March 8, 2021 10:27
@knopp knopp changed the title WIP: Implement delete by word Implement delete by word Mar 8, 2021

@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.

Thanks for submitting this. This sort of key handling is moving out of RenderEditable and into Shortcuts (design doc), but I think it's ok to merge this now. It should be a small refactor to port it to Shortcuts in the future.

I'm curious about how this will work when it encounters spaces. I've tried this out on TextEdit on Mac and put my results in a table below. Can you make sure that this works for all of these cases and write tests to make sure the important ones are covered?

Before Word Modifier + After, according to TextEdit on Mac
text with| multiple words Delete text with| words
text with |multiple words Backspace text |multiple words
text with|     multiple words Delete text with| words
text with     |multiple words Backspace text |multiple words
text with multiple words| Backspace text with multiple |
text with multiple| words Backspace text with | words
text with multiple\n|words Backspace text with |words

@knopp

knopp commented Mar 10, 2021 •

Copy link
Copy Markdown
Member Author

@justinmc, it works exactly like the examples in your table. When there is no selection, it uses existing methods to extend selection to previous/next word (i.e. alt+backspace is equivalent to alt+left, backspace). The shift+arrow+word modifier behavior is already identical to Mac, and thus is deleting the word.

@knopp

knopp commented Mar 11, 2021

Copy link
Copy Markdown
Member Author

@justinmc, I just noticed that backspace and delete are listed in _shortcutKeys, and thus ctrl+backpace and ctrl+delete are processed as shortcuts on linux and windows. However _handleShortcuts doesn't do anything with these keys, and ctrl+delete and ctrl+backspace should delete words just like alt+delete does on Mac. So I don't think putting backspace and delete in shortcuts is the right thing to do, is it?

@justinmc

Copy link
Copy Markdown
Contributor

Ah good catch. That makes sense to me. So keep your code that handles these in _handleDelete, and remove delete and backspace from _shortcutKeys.

That's great that this PR handles all of the cases I wrote out 👍 . Just make sure it's covered in the tests.

@knopp

knopp commented Mar 11, 2021

Copy link
Copy Markdown
Member Author

The tests are in

@justinmc

Copy link
Copy Markdown
Contributor

I really apologize because I should have noticed this sooner, but there is another PR that makes this one obsolete: #77172. I am unfortunately going to have to close this PR, but the good news is that the delete by word functionality should be in Flutter soon anyway.

This is my fault for not realizing that the #77547 and #57015 issues are duplicates. If there is anything in this PR that is not covered by the other one, let me know and we can work on getting that in too.

Thanks for all of your work on this!

@justinmc justinmc closed this Mar 13, 2021
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.

2 participants