Fix MergingBehaviour::Last creating unintuitive import trees #6102
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.
The way this behaviour currently works is actually a bit weird. Imagine the following three imports get requested for insertion in the given order:
winapi::um::d3d11::ID3D11Device
winapi::shared::dxgiformat::DXGI_FORMAT
winapi::um::d3d11::D3D11_FILTER
After the first two you will have the following tree:
which is to be expected as they arent nested this kind of merging is allowed, but now importing the third one will result in:
which is still fine according to the rules, but it looks weird(at least in my eyes) due to the long paths that are quite similar. The changes in this PR will change the criteria for when to reject
Last
merging, it still disallows multiple nesting but it also only allows single segment paths inside of theUseTreeList
. With this change you get the following tree after the first two imports:and after the third:
Which I believe looks more like what you would expect.