-
Notifications
You must be signed in to change notification settings - Fork 55
Remove the select_* methods from PlainEditorDriver
#459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Remove the select_* methods from PlainEditorDriver
#459
Conversation
… an `extend` parameter to the `move_to_*` methods. When `extend` is `true`, the `move_to_*` methods extend the selection.
nicoburns
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change makes a lot of sense to me. However:
- We should document what the
extendparameter does on each of the functions that now has one. - We will need a changelog entry
|
This does seem like a reasonable thing to want. My concern is that it does make code using this functionality harder to follow and understand, due to the standard issues around boolean parameters. That doesn't block this change, but it warrants care. I wonder if there's a better name than |
Yes this bothers me a bit too. I think overall this makes things easier to understand probably though, just because of the smaller API footprint and less branching in user code.
Some half-baked thoughts:
Probably the |
|
I like the idea of an enum. Perhaps: enum SelectionMode {
/// Updates the current selection by moving the focus point to the specified location
Update,
/// Replaces the current selection with a new collapsed selection at the specified location
Replace, // or Move or Collapse
}Perhaps then the methods should be |
Yeah I like that, it carries the right implication, that the cursor's position without a selection is still represented by an empty selection range. |
|
I quite like |
PlainEditorDriverhas about a dozenselect_*functions that have matchingmove_*functions that are identical except that they callset_selection(or whatever) with atruevalue for itsextendparameter. When handling keyboard inputs you check the state of the modifier keys and call the appropriate function:This PR removes
select_*functions and add anextendparameter to its matchingmove_*functions instead, which allows the keyboard handling logic to be simplified like so: