Repository navigation
Implement delete by word - #77549
Implement delete by word#77549knopp wants to merge 4 commits into
Conversation
|
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. |
justinmc
left a comment
There was a problem hiding this comment.
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 |
|
@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. |
|
@justinmc, I just noticed that |
|
Ah good catch. That makes sense to me. So keep your code that handles these in _handleDelete, and remove delete and backspace from That's great that this PR handles all of the cases I wrote out 👍 . Just make sure it's covered in the tests. |
|
The tests are in |
|
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! |
#77547
Implements delete by word for RenderEditable
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.