Skip to content

Commit 0312dd1

Browse files
committed
Added online help
1 parent 921c516 commit 0312dd1

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

package.json

+10
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@
3535
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./"
3636
},
3737
"contributes": {
38+
"keybindings": [{
39+
"command": "PowerShell.OnlineHelp",
40+
"key": "ctrl+f1",
41+
"when": "editorTextFocus"
42+
}],
43+
"commands": [{
44+
"command": "PowerShell.OnlineHelp",
45+
"title": "Get online help for command",
46+
"category": "PowerShell"
47+
}],
3848
"languages": [{
3949
"id": "PowerShell",
4050
"extensions": [ ".ps1", ".psm1", ".psd1", ".pssc", ".psrc" ],

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)