-
Notifications
You must be signed in to change notification settings - Fork 141
Description
Because detection of the relevant root module for a file/dir is not a trivial task, #176 introduces new functionality which reports all potential candidates for root modules in the context of a directory being initialized/opened, matches the first one and displays warning when there is more than 1.
Picking the right root module from a list of candidates is something that #176 does not solve yet, because there is a number of different factors which may play role in picking.
Use-cases
Assuming the root (.
) below is the root being opened in the IDE:
.
|-- .terraform
|-- module-one
| `-- main.tf
|-- main.tf
`-- module-two
|-- .terraform
|-- main.tf
`-- module-three
`-- main.tf
both the ./main.tf
and ./module-two/main.tf
reference module-three
, and both are init
d.
The user will in this case receive a warning, module-two
was found as an alternative root module and LS picked the root (.
), which in most cases is probably wrong choice.
Proposal
We can assume that the reference in the above example in ./module-two/main.tf
is more relevant, because it's just 1 level away. In case where module-three
is init
d itself, then that becomes the best (and only) candidate for "itself".
Generally the fewer directories in the hierarchy away from the file being opened, more relevant the root module should be.
This still probably leaves room for some unsolvable situations, where 2+ directories are on the same level, but that ambiguity can be solved by further sorting candidates using different techniques.