Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
13 changes: 0 additions & 13 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,6 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
const projectManager: PythonProjectManager = new PythonProjectManagerImpl();
context.subscriptions.push(projectManager);

// Helper function to check if a resource is an existing Python project
const isExistingProject = (uri: Uri | undefined): boolean => {
if (!uri) {
return false;
}
return projectManager.get(uri) !== undefined;
};

const envVarManager: EnvVarManager = new PythonEnvVariableManager(projectManager);
context.subscriptions.push(envVarManager);

Expand Down Expand Up @@ -323,11 +315,6 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
});
}),
commands.registerCommand('python-envs.addPythonProjectGivenResource', async (resource) => {
// 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, {
Expand Down
12 changes: 10 additions & 2 deletions src/features/creators/autoFindProjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 10 additions & 2 deletions src/features/creators/existingProjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading