diff --git a/package.json b/package.json index 31887629..4383db75 100644 --- a/package.json +++ b/package.json @@ -489,12 +489,12 @@ { "command": "python-envs.addPythonProjectGivenResource", "group": "inline", - "when": "explorerViewletVisible && explorerResourceIsFolder && !python-envs:isExistingProject" + "when": "explorerViewletVisible && explorerResourceIsFolder" }, { "command": "python-envs.addPythonProjectGivenResource", "group": "inline", - "when": "explorerViewletVisible && resourceExtname == .py && !python-envs:isExistingProject" + "when": "explorerViewletVisible && resourceExtname == .py" } ], "editor/title/run": [ diff --git a/src/extension.ts b/src/extension.ts index c4d89ec8..22b2f658 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -189,14 +189,6 @@ export async function activate(context: ExtensionContext): Promise { - if (!uri) { - return false; - } - return projectManager.get(uri) !== undefined; - }; - const envVarManager: EnvVarManager = new PythonEnvVariableManager(projectManager); context.subscriptions.push(envVarManager); @@ -323,11 +315,6 @@ export async function activate(context: ExtensionContext): Promise { - // Set context to show/hide menu item depending on whether the resource is already a Python project - if (resource instanceof Uri) { - commands.executeCommand('setContext', 'python-envs:isExistingProject', isExistingProject(resource)); - } - await addPythonProjectCommand(resource, projectManager, envManagers, projectCreators); const totalProjectCount = projectManager.getProjects().length + 1; sendTelemetryEvent(EventNames.ADD_PROJECT, undefined, { diff --git a/src/features/creators/autoFindProjects.ts b/src/features/creators/autoFindProjects.ts index cb1258e6..7d3987c9 100644 --- a/src/features/creators/autoFindProjects.ts +++ b/src/features/creators/autoFindProjects.ts @@ -83,9 +83,17 @@ export class AutoFindProjects implements PythonProjectCreator { if (filtered.length === 0) { // No new projects found that are not already in the project manager - traceInfo('All discovered projects are already registered in the project manager'); + traceInfo( + `All selected resources are already registered in the project manager: ${files + .map((uri) => uri.fsPath) + .join(', ')}`, + ); setImmediate(() => { - showWarningMessage('No new projects found'); + if (files.length === 1) { + showWarningMessage(`${files[0].fsPath} already exists as project.`); + } else { + showWarningMessage('Selected resources already exist as projects.'); + } }); return; } diff --git a/src/features/creators/existingProjects.ts b/src/features/creators/existingProjects.ts index 1bb6ff0c..5c66d29b 100644 --- a/src/features/creators/existingProjects.ts +++ b/src/features/creators/existingProjects.ts @@ -56,9 +56,17 @@ export class ExistingProjects implements PythonProjectCreator { if (filtered.length === 0) { // No new projects found that are not already in the project manager - traceInfo('All discovered projects are already registered in the project manager'); + const formattedProjectPaths = + existingAddUri === undefined ? 'None' : existingAddUri.map((uri) => uri.fsPath).join(', '); + traceInfo( + `All selected resources are already registered in the project manager. Resources selected: ${formattedProjectPaths}`, + ); setImmediate(() => { - showWarningMessage('No new projects found'); + if (existingAddUri && existingAddUri.length === 1) { + showWarningMessage(`Selected resource already exists as project.`); + } else { + showWarningMessage('Selected resources already exist as projects.'); + } }); return; }