Skip to content

Commit

Permalink
Change "Get Online Help" menu item label: remove Online. (#1516)
Browse files Browse the repository at this point in the history
* Change Menu label: remove Online.
* We now look for help locally if it's not availble online.
* Rename the file to ShowHelp.
* Add a command for PowerShell.ShowHelp and mark OnlineHelp as deprecated.
* Display warning when OnlineHelp is called and then execute ShowHelp.
* Remove showOnlineHelp requestType as it's not used.
  • Loading branch information
corbob authored and rjmholt committed Sep 21, 2018
1 parent 1f819e2 commit ab40a53
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"contributes": {
"keybindings": [
{
"command": "PowerShell.OnlineHelp",
"command": "PowerShell.ShowHelp",
"key": "ctrl+f1",
"when": "editorTextFocus && editorLangId == 'powershell'"
},
Expand Down Expand Up @@ -88,7 +88,12 @@
},
{
"command": "PowerShell.OnlineHelp",
"title": "Get Online Help for Command",
"title": "Get Online Help for Command (Deprecated)",
"category": "PowerShell"
},
{
"command": "PowerShell.ShowHelp",
"title": "Get Help for Command",
"category": "PowerShell"
},
{
Expand Down Expand Up @@ -166,7 +171,7 @@
},
{
"when": "editorLangId == powershell",
"command": "PowerShell.OnlineHelp",
"command": "PowerShell.ShowHelp",
"group": "2_powershell"
}
]
Expand Down
18 changes: 12 additions & 6 deletions src/features/ShowOnlineHelp.ts → src/features/ShowHelp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,40 @@ import vscode = require("vscode");
import { LanguageClient, NotificationType, RequestType } from "vscode-languageclient";
import { IFeature } from "../feature";

export const ShowOnlineHelpRequestType =
new RequestType<string, void, void, void>("powerShell/showOnlineHelp");
export const ShowHelpRequestType =
new RequestType<string, void, void, void>("powerShell/showHelp");

export class ShowHelpFeature implements IFeature {

private command: vscode.Disposable;
private deprecatedCommand: vscode.Disposable;
private languageClient: LanguageClient;

constructor() {
this.command = vscode.commands.registerCommand("PowerShell.OnlineHelp", () => {
this.command = vscode.commands.registerCommand("PowerShell.ShowHelp", () => {
if (this.languageClient === undefined) {
// TODO: Log error message
return;
}

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.sendRequest(ShowOnlineHelpRequestType, text);
this.languageClient.sendRequest(ShowHelpRequestType, text);
});

this.deprecatedCommand = vscode.commands.registerCommand("PowerShell.OnlineHelp", () => {
const warnText = "PowerShell.OnlineHelp is being deprecated. Use PowerShell.ShowHelp instead.";
vscode.window.showWarningMessage(warnText);
vscode.commands.executeCommand("PowerShell.ShowHelp");
});
}

public dispose() {
this.command.dispose();
this.deprecatedCommand.dispose();
}

public setLanguageClient(languageclient: LanguageClient) {
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { OpenInISEFeature } from "./features/OpenInISE";
import { PesterTestsFeature } from "./features/PesterTests";
import { RemoteFilesFeature } from "./features/RemoteFiles";
import { SelectPSSARulesFeature } from "./features/SelectPSSARules";
import { ShowHelpFeature } from "./features/ShowOnlineHelp";
import { ShowHelpFeature } from "./features/ShowHelp";
import { Logger, LogLevel } from "./logging";
import { SessionManager } from "./session";
import Settings = require("./settings");
Expand Down

0 comments on commit ab40a53

Please sign in to comment.