Fix some import module completions being dropped (and fix flaky test too) #2595
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.
Fixes #2577 and maybe other issues involving import module completions.
The superficial reason why the module completions test was failing is that
HashMap
'stoList
ordering is not deterministic between runs. This meant that the list ordering of the target files/modules would occur in different orders.Of course why should the order of module names affect anything with regards to completions?
The test generates 3 targets, 2
TargetModule
s and 1TargetFile
. Since we seem to only care about actual modules we convertTargetFile
s to empty strings. This list of module names (including the empty string) eventually get passed to the fuzzy matcher which attempts to run the matcher on the names in parallel.Interestingly different orders can cause the parallel strategy to give different results which should be impossible unless the
Strategy
changes its input. Therefore the strategy does change its input.Turns out the function used to chunk vectors had an off-by-one error when doing the
Vector
chunking, and if the empty string wasn't in the last position some module completions would be dropped.e.g.
Also interesting is the comment on the
chunkVector
function seems to have come from eval plugin usage and has the correct output underneath it, yet when I eventually ran the eval plugin for kicks it produced the wrong output 😅The fix is just adding
+1
to the slice length.