Skip to content

Commit efcde4d

Browse files
committed
Add 'Open Examples Folder' command
This change introduces a new command called "Open Examples Folder" which opens the bundled folder of example scripts. This saves us from having to tell people where to find the folder since it's not the easiest path to get to.
1 parent 6431df3 commit efcde4d

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"main": "./out/main",
2828
"activationEvents": [
2929
"onLanguage:powershell",
30-
"onCommand:PowerShell.NewProjectFromTemplate"
30+
"onCommand:PowerShell.NewProjectFromTemplate",
31+
"onCommand:PowerShell.OpenExamplesFolder"
3132
],
3233
"dependencies": {
3334
"vscode-languageclient": "1.3.1"
@@ -139,6 +140,11 @@
139140
"command": "PowerShell.NewProjectFromTemplate",
140141
"title": "Create New Project from Plaster Template",
141142
"category": "PowerShell"
143+
},
144+
{
145+
"command": "PowerShell.OpenExamplesFolder",
146+
"title": "Open Examples Folder",
147+
"category": "PowerShell"
142148
}
143149
],
144150
"snippets": [

src/features/Examples.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*---------------------------------------------------------
2+
* Copyright (C) Microsoft Corporation. All rights reserved.
3+
*--------------------------------------------------------*/
4+
5+
import vscode = require('vscode');
6+
import path = require('path');
7+
import { IFeature } from '../feature';
8+
import { LanguageClient } from 'vscode-languageclient';
9+
10+
export class ExamplesFeature implements IFeature {
11+
private command: vscode.Disposable;
12+
private examplesPath: string;
13+
14+
constructor() {
15+
this.examplesPath = path.resolve(__dirname, "../../examples");
16+
this.command = vscode.commands.registerCommand('PowerShell.OpenExamplesFolder', () => {
17+
vscode.commands.executeCommand(
18+
"vscode.openFolder",
19+
vscode.Uri.file(this.examplesPath),
20+
true);
21+
});
22+
}
23+
24+
public setLanguageClient(languageclient: LanguageClient) {
25+
}
26+
27+
public dispose() {
28+
this.command.dispose();
29+
}
30+
}

0 commit comments

Comments
 (0)