-
-
Notifications
You must be signed in to change notification settings - Fork 88
New interface for performing edits and updating ranges #2551
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
Conversation
Proposed new interface: const {
sourceEditRanges: updatedSourceEditRanges,
destinationEditRanges: updatedDestinationEditRanges,
} = await performEditsAndUpdateSelections({
rangeUpdator,
editor: editableEditor,
edits: filteredEdits.map(({ edit }) => edit),
// callback: async () => {...do whatever},
selections: {
sourceEditRanges,
destinationEditRanges: {
selections: destinationEditRanges,
behavior: RangeExpansionBehavior.openOpen,
},
},
// preserveEditorSelections: true,
}); In the future we can do something fancier eg put it on the Note that the values in the map passed to |
@pokey Updated according to the new interface now |
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.
bunch of very minor nits. Feel free to merge once you've addressed the ones that seem important enough to address 😅
Happy with how the interface turned out tho; nice to rip out all those extra functions
const { contentRanges: updatedRanges } = | ||
await performEditsAndUpdateSelections({ | ||
rangeUpdater: this.rangeUpdater, | ||
editor: editableEditor, | ||
edits, | ||
selections: { | ||
contentRanges, | ||
}, | ||
}); |
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.
tempting to have shorthand
const { contentRanges: updatedRanges } = | |
await performEditsAndUpdateSelections({ | |
rangeUpdater: this.rangeUpdater, | |
editor: editableEditor, | |
edits, | |
selections: { | |
contentRanges, | |
}, | |
}); | |
const updatedRanges = | |
await performEditsAndUpdateSelections({ | |
rangeUpdater: this.rangeUpdater, | |
editor: editableEditor, | |
edits, | |
selections: contentRanges, | |
}); |
but that might be getting a bit too overloaded 😅
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.
Yeah I think that is to much
packages/cursorless-engine/src/actions/EditNew/runEditTargets.ts
Outdated
Show resolved
Hide resolved
packages/cursorless-engine/src/core/updateSelections/updateSelections.ts
Outdated
Show resolved
Hide resolved
packages/cursorless-engine/src/core/updateSelections/updateSelections.ts
Outdated
Show resolved
Hide resolved
packages/cursorless-engine/src/core/updateSelections/updateSelections.ts
Show resolved
Hide resolved
packages/cursorless-engine/src/core/updateSelections/updateSelections.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Pokey Rule <[email protected]>
…ections.ts Co-authored-by: Pokey Rule <[email protected]>
This introduces a new interface to perform updates. The requirements I had was:
What this pr doesn't try to do:
Example
Ponderings
EditsUpdater
andCallbackUpdater
. I'm a bit tempted to just use a single class and a polymorphic argument.editsOrCallback: Edit[] | () => Promise<void>
. Something like that.If we embrace this polymorphic nature it could look something like this:
Personally I am a fan of the above since it became cleaner and simpler, but I know that @pokey generally doesn't prefer union arguments if it can be avoided.
We could of course get rid of
new
if we wanted to make it even cleaner.Related to #729
Checklist