-
Notifications
You must be signed in to change notification settings - Fork 511
/
Copy pathShowHelp.ts
38 lines (29 loc) · 1.22 KB
/
ShowHelp.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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import vscode = require("vscode");
import { NotificationType } from "vscode-languageclient";
import { Logger } from "../logging";
import { LanguageClientConsumer } from "../languageClientConsumer";
export const ShowHelpNotificationType =
new NotificationType<any>("powerShell/showHelp");
export class ShowHelpFeature extends LanguageClientConsumer {
private command: vscode.Disposable;
constructor(private log: Logger) {
super();
this.command = vscode.commands.registerCommand("PowerShell.ShowHelp", (item?) => {
if (!item || !item.Name) {
const editor = vscode.window.activeTextEditor;
const selection = editor.selection;
const doc = editor.document;
const cwr = doc.getWordRangeAtPosition(selection.active);
const text = doc.getText(cwr);
this.languageClient.sendNotification(ShowHelpNotificationType, { text });
} else {
this.languageClient.sendNotification(ShowHelpNotificationType, { text: item.Name } );
}
});
}
public dispose() {
this.command.dispose();
}
}