Skip to main content

WalkUpToProjectRoot

Function WalkUpToProjectRoot 

Source
fn WalkUpToProjectRoot(Start: &Path) -> PathBuf
Expand description

Walk up from Start looking for a project-root marker (Cargo.toml, package.json, .git, pyproject.toml, go.mod, pnpm-workspace.yaml). Returns the first ancestor that owns one. Falls back to Start itself when nothing matches before the filesystem root.

Why: when a developer launches the binary from a Target/debug/ build directory, current_dir() is the build folder, which has no source files. vscode.workspace.findFiles('**/*') walks it and returns nothing; the SCM panel can’t find a repo; tree-views render empty. Walking up to the nearest project root mirrors what every git/cargo/npm CLI does and gives extensions a workspace folder they can actually scan.