-
Notifications
You must be signed in to change notification settings - Fork 171
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
Share target finding logic between paste and one-shot insertion #4369
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Job #8665: Bundle Size — 63.28MiB (~+0.01%).
Warning Bundle contains 64 duplicate packages – View duplicate packages Bundle metrics
Bundle size by type
View job #8665 report View feature/insert-target-finding branch activity |
…to feature/insert-target-finding
bkrmendy
changed the title
Share target finding function between paste and one-shot insertion
Share target finding logic between paste and one-shot insertion
Oct 16, 2023
balazsbajorics
approved these changes
Oct 16, 2023
bkrmendy
requested review from
gbalint,
seanparsons,
Rheeseyb,
ruggi and
enidemi
October 16, 2023 12:10
gbalint
approved these changes
Oct 16, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When adding an element via A for Add (the one-shot insertion), the action will often fail because the selected element does not support children. This is because we try to add the element always only into the selected element.
Fix
Use the same logic to find a target parent we use for pasting (after some refactoring). The way this is accomplished is that
getTargetParentForPaste
is refactored into smaller target finding functions (checkComponentNotInsertedIntoOwnDefinition
,insertIntoSlot
,pasteNextToSameSizedElement
,pasteIntoParentOrGrandparent
), and a new target finding function is created (getTargetParentForOneShotInsertion
), which is made up of these smaller functions.The reason the two functions cannot be the same is that
pasteNextToSameSizedElement
expects the newly inserted elements to already have metadata, and elements inserted via one-shot insertion don't have any metadata.