Skip to content

Commit d1ac93b

Browse files
Copiloteleanorjboyd
andcommitted
Implement reveal project in explorer command
Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
1 parent ceb22d0 commit d1ac93b

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@
255255
"command": "python-envs.reportIssue",
256256
"title": "%python-envs.reportIssue.title%",
257257
"category": "Python Environments"
258+
},
259+
{
260+
"command": "python-envs.revealProjectInExplorer",
261+
"title": "%python-envs.revealProjectInExplorer.title%",
262+
"category": "Python Envs",
263+
"icon": "$(folder-opened)"
258264
}
259265
],
260266
"menus": {
@@ -326,6 +332,10 @@
326332
{
327333
"command": "python-envs.createAny",
328334
"when": "false"
335+
},
336+
{
337+
"command": "python-envs.revealProjectInExplorer",
338+
"when": "false"
329339
}
330340
],
331341
"view/item/context": [
@@ -395,6 +405,11 @@
395405
"group": "inline",
396406
"when": "view == python-projects && viewItem =~ /.*python-workspace.*/"
397407
},
408+
{
409+
"command": "python-envs.revealProjectInExplorer",
410+
"group": "inline",
411+
"when": "view == python-projects && viewItem =~ /.*python-workspace.*/"
412+
},
398413
{
399414
"command": "python-envs.uninstallPackage",
400415
"group": "inline",

package.nls.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@
3434
"python-envs.createNewProjectFromTemplate.title": "Create New Project from Template",
3535
"python-envs.terminal.activate.title": "Activate Environment in Current Terminal",
3636
"python-envs.terminal.deactivate.title": "Deactivate Environment in Current Terminal",
37-
"python-envs.uninstallPackage.title": "Uninstall Package"
37+
"python-envs.uninstallPackage.title": "Uninstall Package",
38+
"python-envs.revealProjectInExplorer.title": "Reveal Project in Explorer"
3839
}

src/extension.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
refreshPackagesCommand,
3333
removeEnvironmentCommand,
3434
removePythonProject,
35+
revealProjectInExplorer,
3536
runAsTaskCommand,
3637
runInDedicatedTerminalCommand,
3738
runInTerminalCommand,
@@ -356,6 +357,9 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
356357
commands.registerCommand('python-envs.copyProjectPath', async (item) => {
357358
await copyPathToClipboard(item);
358359
}),
360+
commands.registerCommand('python-envs.revealProjectInExplorer', async (item) => {
361+
await revealProjectInExplorer(item);
362+
}),
359363
commands.registerCommand('python-envs.terminal.activate', async () => {
360364
const terminal = activeTerminal();
361365
if (terminal) {

src/features/envCommands.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,3 +649,13 @@ export async function copyPathToClipboard(item: unknown): Promise<void> {
649649
traceVerbose(`Invalid context for copy path to clipboard: ${item}`);
650650
}
651651
}
652+
653+
export async function revealProjectInExplorer(item: unknown): Promise<void> {
654+
if (item instanceof ProjectItem) {
655+
const projectUri = item.project.uri;
656+
await commands.executeCommand('revealFileInOS', projectUri);
657+
traceInfo(`Revealed project in explorer: ${projectUri.fsPath}`);
658+
} else {
659+
traceVerbose(`Invalid context for reveal project in explorer: ${item}`);
660+
}
661+
}

0 commit comments

Comments
 (0)