Skip to content

Commit 307f8ba

Browse files
authored
add command to add Python project given resource (#514)
fixes #450
1 parent 4b10b39 commit 307f8ba

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

package.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@
124124
"category": "Python",
125125
"icon": "$(new-folder)"
126126
},
127+
{
128+
"command": "python-envs.addPythonProjectGivenResource",
129+
"title": "%python-envs.addPythonProjectGivenResource.title%",
130+
"category": "Python",
131+
"icon": "$(new-folder)"
132+
},
127133
{
128134
"command": "python-envs.removePythonProject",
129135
"title": "%python-envs.removePythonProject.title%",
@@ -282,6 +288,10 @@
282288
"command": "python-envs.addPythonProject",
283289
"when": "false"
284290
},
291+
{
292+
"command": "python-envs.addPythonProjectGivenResource",
293+
"when": "false"
294+
},
285295
{
286296
"command": "python-envs.removePythonProject",
287297
"when": "false"
@@ -440,12 +450,12 @@
440450
],
441451
"explorer/context": [
442452
{
443-
"command": "python-envs.addPythonProject",
453+
"command": "python-envs.addPythonProjectGivenResource",
444454
"group": "inline",
445455
"when": "explorerViewletVisible && explorerResourceIsFolder && !python-envs:isExistingProject"
446456
},
447457
{
448-
"command": "python-envs.addPythonProject",
458+
"command": "python-envs.addPythonProjectGivenResource",
449459
"group": "inline",
450460
"when": "explorerViewletVisible && resourceExtname == .py && !python-envs:isExistingProject"
451461
}
@@ -545,4 +555,4 @@
545555
"vscode-jsonrpc": "^9.0.0-next.5",
546556
"which": "^4.0.0"
547557
}
548-
}
558+
}

package.nls.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"python-envs.terminal.revertStartupScriptChanges.title": "Revert Shell Startup Script Changes",
1414
"python-envs.setEnvManager.title": "Set Environment Manager",
1515
"python-envs.setPkgManager.title": "Set Package Manager",
16-
"python-envs.addPythonProject.title": "Add as Python Project",
16+
"python-envs.addPythonProject.title": "Add Python Project",
17+
"python-envs.addPythonProjectGivenResource.title": "Add as Python Project",
1718
"python-envs.removePythonProject.title": "Remove Python Project",
1819
"python-envs.copyEnvPath.title": "Copy Environment Path",
1920
"python-envs.copyProjectPath.title": "Copy Project Path",

src/extension.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
195195
commands.registerCommand('python-envs.setPkgManager', async () => {
196196
await setPackageManagerCommand(envManagers, projectManager);
197197
}),
198-
commands.registerCommand('python-envs.addPythonProject', async (resource) => {
198+
commands.registerCommand('python-envs.addPythonProject', async () => {
199+
await addPythonProjectCommand(undefined, projectManager, envManagers, projectCreators);
200+
}),
201+
commands.registerCommand('python-envs.addPythonProjectGivenResource', async (resource) => {
199202
// Set context to show/hide menu item depending on whether the resource is already a Python project
200203
if (resource instanceof Uri) {
201204
commands.executeCommand('setContext', 'python-envs:isExistingProject', isExistingProject(resource));

0 commit comments

Comments
 (0)