Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/appDiscovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export async function discoverFastAPIApps(

let candidates: EntryPoint[]

// If user specified an entry point in settings, use that
if (customEntryPoint) {
const entryPath = isAbsolute(customEntryPoint)
? customEntryPoint
Expand All @@ -118,6 +119,7 @@ export async function discoverFastAPIApps(

candidates = [{ filePath: entryPath }]
} else {
// Otherwise, check pyproject.toml or auto-detect
const pyprojectEntry = await parsePyprojectForEntryPoint(
folder.uri.fsPath,
)
Expand All @@ -126,6 +128,14 @@ export async function discoverFastAPIApps(
: (await automaticDetectEntryPoints(folder.uri.fsPath)).map(
(filePath) => ({ filePath }),
)

// If no candidates found, try the active editor as a last resort
if (candidates.length === 0) {
const activeEditor = vscode.window.activeTextEditor
if (activeEditor?.document.languageId === "python") {
candidates = [{ filePath: activeEditor.document.uri.fsPath }]
}
}
}

for (const candidate of candidates) {
Expand Down