fmt: don't change paths when formatting imports #21148
Merged
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.
@spytheman your point made here #21134 (comment) confirms itself.
With our current module lookup there are more scenarios where it is required to keep the a
src.
part in the import. E.g. in v-analyzer forbuild.vsh
(src.metadata
) or intools/project-checker.v
. By removing thesrc.
prefix vfmt would break the functionality, since the imported modules are not found anymore.Now vfmt would not try to "outsmart" anymore. And for scenarios where an import prefixed with
src.
and as well as the path withoutsrc.
are valid, both will be also seen as valid by vfmt.General formatting will still happen ofc, unused import symbols will be cleared, just the path of the import won't be changed anymore.
The tests that check for the import path update were removed. All other behavior is tested due to older and recently added tests, the changes should be covered.