-
Notifications
You must be signed in to change notification settings - Fork 510
/
Copy pathShowOnlineHelp.ts
43 lines (33 loc) · 1.36 KB
/
ShowOnlineHelp.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
import vscode = require('vscode');
import { IFeature } from '../feature';
import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient';
export namespace ShowOnlineHelpRequest {
export const type = new RequestType<string, void, void, void>('powerShell/showOnlineHelp');
}
export class ShowHelpFeature implements IFeature {
private command: vscode.Disposable;
private languageClient: LanguageClient;
constructor() {
this.command = vscode.commands.registerCommand('PowerShell.OnlineHelp', () => {
if (this.languageClient === undefined) {
// TODO: Log error message
return;
}
const editor = vscode.window.activeTextEditor;
var selection = editor.selection;
var doc = editor.document;
var cwr = doc.getWordRangeAtPosition(selection.active)
var text = doc.getText(cwr);
this.languageClient.sendRequest(ShowOnlineHelpRequest.type, text);
});
}
public setLanguageClient(languageclient: LanguageClient) {
this.languageClient = languageclient;
}
public dispose() {
this.command.dispose();
}
}