Skip to content

Commit 82a70b7

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 82a70b7

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

package.json

+7-1
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

+30
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+
}

src/main.ts

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { IFeature } from './feature';
1010
import { SessionManager } from './session';
1111
import { PowerShellLanguageId } from './utils';
1212
import { ConsoleFeature } from './features/Console';
13+
import { ExamplesFeature } from './features/Examples';
1314
import { OpenInISEFeature } from './features/OpenInISE';
1415
import { NewFileOrProjectFeature } from './features/NewFileOrProject';
1516
import { ExpandAliasFeature } from './features/ExpandAlias';
@@ -88,6 +89,7 @@ export function activate(context: vscode.ExtensionContext): void {
8889
// Create features
8990
extensionFeatures = [
9091
new ConsoleFeature(),
92+
new ExamplesFeature(),
9193
new OpenInISEFeature(),
9294
new ExpandAliasFeature(),
9395
new ShowHelpFeature(),

0 commit comments

Comments
 (0)