Skip to content

Commit 0042484

Browse files
committed
Merge pull request #21 from PowerShell/dfinke/online-help
Added online help
2 parents 4d2aafb + b5be58c commit 0042484

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

package.json

+20
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,26 @@
3838
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./"
3939
},
4040
"contributes": {
41+
"keybindings": [{
42+
"command": "PowerShell.OnlineHelp",
43+
"key": "ctrl+f1",
44+
"when": "editorTextFocus"
45+
}],
46+
"commands": [{
47+
"command": "PowerShell.OnlineHelp",
48+
"title": "Get online help for command",
49+
"category": "PowerShell"
50+
}],
51+
"languages": [{
52+
"id": "PowerShell",
53+
"extensions": [ ".ps1", ".psm1", ".psd1", ".pssc", ".psrc" ],
54+
"aliases": [ "PowerShell", "powershell", "ps", "ps1" ]
55+
}],
56+
"grammars": [{
57+
"language": "PowerShell",
58+
"scopeName": "source.powershell",
59+
"path": "./syntaxes/PowerShell.tmLanguage"
60+
}],
4161
"snippets": [
4262
{
4363
"language": "powershell",

src/features/ShowOnlineHelp.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { RequestType, NotificationType, ResponseError } from 'vscode-jsonrpc';
2+
3+
export namespace ShowOnlineHelpRequest {
4+
export const type: RequestType<string, void, void> = { get method() { return 'showonlinehelp'; } };
5+
}

src/main.ts

+17-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ import vscode = require('vscode');
99
import configuration = require('./features/configuration');
1010
import { LanguageClient, LanguageClientOptions, Executable } from 'vscode-languageclient';
1111

12+
import { RequestType, NotificationType, ResponseError } from 'vscode-jsonrpc';
13+
import powerShellMessage = require('./features/ShowOnlineHelp');
14+
1215
export function activate(context: vscode.ExtensionContext): void {
1316

1417
var PowerShellLanguageId = 'PowerShell';
1518

16-
vscode.languages.setLanguageConfiguration(PowerShellLanguageId,
19+
vscode.languages.setLanguageConfiguration(PowerShellLanguageId,
1720
{
1821
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\=\+\[\{\]\}\\\|\;\'\"\,\.\<\>\/\?\s]+)/g,
1922

@@ -81,7 +84,19 @@ export function activate(context: vscode.ExtensionContext): void {
8184
serverOptions,
8285
clientOptions);
8386

84-
client.start();
87+
client.start();
88+
89+
var disposable = vscode.commands.registerCommand('PowerShell.OnlineHelp', () => {
90+
91+
const editor = vscode.window.activeTextEditor;
92+
93+
var selection = editor.selection;
94+
var doc = editor.document;
95+
var cwr = doc.getWordRangeAtPosition(selection.active)
96+
var text = doc.getText(cwr);
97+
98+
client.sendRequest(powerShellMessage.ShowOnlineHelpRequest.type, text);
99+
});
85100
}
86101

87102
function resolveLanguageServerPath() : string {

0 commit comments

Comments
 (0)