Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
When a user goes to open a template from within our built-in template editor, it tries to auto-select the main.tf
file, as that will likely be there the majority of the code will live. This works fine for simpler templates.
The problem is that, when you have multiple main.tf
files (e.g., one at the root directory, and another in a sub-directory), the auto-selection logic seems to try to select the first main.tf
file it can find. As subdirectories are listed first in the editor, that means that the less relevant, secondary main.tf
file will always be selected, and the user has to click the correct one.
Relevant Log Output
N/A
Expected Behavior
When a user opens a template in the built-in editor, the auto-selection logic will favor the main.tf
file at the root directory (if it exists). All other main.tf
files will not be eligible for auto-selection, so if the root file is missing, the main text area will start off empty.
Steps to Reproduce
- Create a template with two
main.tf
files. One should go in the root directory, and the other should go in a subdirectory - Open the template in the built-in web editor
- See that the subdirectory's
main.tf
file is selected, even if it barely has any bearing on the overall template functionality
Note for Dogfood: this already applies to the current Coder on Coder template
Environment
- Host OS: Dogfood
- Coder version: v2.18.5