Skip to content

Commit 1626c3f

Browse files
authored
Merge pull request PowerShell#428 from PowerShell/daviwil/open-examples
Add 'Open Examples Folder' command
2 parents 6431df3 + 82a70b7 commit 1626c3f

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)