godotengine / godotengine/godot-vscode-plugin

The "first" godot.project file that gets picked by the extension is not always intuitive

Open
#921 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
2.1k
Forks
257
PR merge metrics
No merged PRs in 30d

Description

### Godot version

4.4.1

### VS Code version

1.103.2

### Godot Tools VS Code extension version

2.5.1

### System information

MacOS Ventura

### Issue description

The "first" godot.project file that gets picked by the extension is not always intuitive.

In `godot_utils` the `get_project_dir` function picks the "top-most" `godot.project` file based on the shortest fsPath length. This generally works, but has 2 issues:

## Multi-root workspaces
In multi-root workspaces, the shortest path may not be the first project folder. In such cases, there's no way to organize the workspace to control the project that gets picked. e.g. the following `code-workspace` file will always pick the `/another/godot/project` project since it has a shorter fs path length.

```jsonc
{
"folders": [
{
"path": "/some/path/to/a/godot/project"
},
{
// This project will always get picked
"path": "/another/godot/project"
}
]
}
```

## Single-root workspaces
In single-root workspaces, the shortest path length may not always be the first one in the fs order if there are multiple projects at same folder level but 2nd folder has a shorter name. e.g. the 2nd project will be selected in this case:

```
game
/folder-with-long-name
godot.project
/short-name
godot.project
```

### Steps to reproduce

Setup a multi-root workspace where the folder paths have different lengths and each contains a godot.project file. The one with the shortest fs path length will always be used.

In a single root workspace, create 2 subfolders with different name lengths each containing a godot.project file. Don't include a godot.project file in the root. Whichever folder has the shortest fs path name will win regardless of fs sort order

Contributor guide

Open the contributing guide

Research direction

Start with the get_project_dir function in godot_utils and reproduce the multi-root and single-root workspace cases described in the issue using multiple godot.project files. Trace how candidate paths are ordered, then verify that the selected project follows the intended workspace or filesystem order rather than the shortest fsPath length.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.