From 9211bc28339e291c76afba92b492a19158c66bf2 Mon Sep 17 00:00:00 2001 From: corbob Date: Mon, 3 Sep 2018 06:28:37 -0700 Subject: [PATCH 1/4] Change Menu label: remove Online. We now look for help locally if it's not availble online. Perhaps to do: remove references to Online from internal commands? --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c9ba7ae80d..0cbe4e0a91 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ }, { "command": "PowerShell.OnlineHelp", - "title": "Get Online Help for Command", + "title": "Get Help for Command", "category": "PowerShell" }, { From e0352db3db3c78a0bf92e987dd0e5c463949167c Mon Sep 17 00:00:00 2001 From: corbob Date: Sat, 15 Sep 2018 19:46:02 -0700 Subject: [PATCH 2/4] Rename the file to ShowHelp. Continue removing word Online Add a command for PowerShell.ShowHelp and mark OnlineHelp as deprecated. Display warning when OnlineHelp is called and then execute ShowHelp. --- package.json | 13 +++++- src/features/ShowHelp.ts | 74 ++++++++++++++++++++++++++++++++++ src/features/ShowOnlineHelp.ts | 42 ------------------- src/main.ts | 2 +- 4 files changed, 86 insertions(+), 45 deletions(-) create mode 100644 src/features/ShowHelp.ts delete mode 100644 src/features/ShowOnlineHelp.ts diff --git a/package.json b/package.json index 0cbe4e0a91..ea353cc9a0 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "contributes": { "keybindings": [ { - "command": "PowerShell.OnlineHelp", + "command": "PowerShell.ShowHelp", "key": "ctrl+f1", "when": "editorTextFocus && editorLangId == 'powershell'" }, @@ -88,8 +88,17 @@ }, { "command": "PowerShell.OnlineHelp", + "title": "Get Online Help for Command(Deprecated)", + "category": "PowerShell" + }, + { + "command": "PowerShell.ShowHelp", "title": "Get Help for Command", "category": "PowerShell" + },{ + "command": "PowerShell.ShowOnlineHelp", + "title": "Dummy command. Shouldn't be released...", + "category": "PowerShell" }, { "command": "PowerShell.RunSelection", @@ -166,7 +175,7 @@ }, { "when": "editorLangId == powershell", - "command": "PowerShell.OnlineHelp", + "command": "PowerShell.ShowHelp", "group": "2_powershell" } ] diff --git a/src/features/ShowHelp.ts b/src/features/ShowHelp.ts new file mode 100644 index 0000000000..5959eb3c09 --- /dev/null +++ b/src/features/ShowHelp.ts @@ -0,0 +1,74 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +import vscode = require("vscode"); +import { LanguageClient, NotificationType, RequestType } from "vscode-languageclient"; +import { IFeature } from "../feature"; + +export const ShowOnlineHelpRequestType = + new RequestType("powerShell/showOnlineHelp"); + // I think we can take out the ShowOnlineHelpRequestType... I don't think we actually send it... +export const ShowHelpRequestType = + new RequestType("powerShell/showHelp"); +export class ShowHelpFeature implements IFeature { + + private command: vscode.Disposable; + private deprecatedCommand: vscode.Disposable; + // TODO: Remove Dummy command before merge. + // Dummy command is used to test out the write-warning in PSES + // when you send powerShell/showOnlineHelp instead of powerShell/showHelp. + private dummyCommand: vscode.Disposable; + private languageClient: LanguageClient; + + constructor() { + // TODO: Remove this before merge. + this.dummyCommand = vscode.commands.registerCommand("PowerShell.ShowOnlineHelp", () => { + 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.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(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(); + // TODO: Remove this dummyCommand too... + // Don't forget the one in package.json + this.dummyCommand.dispose(); + } + + public setLanguageClient(languageclient: LanguageClient) { + this.languageClient = languageclient; + } +} diff --git a/src/features/ShowOnlineHelp.ts b/src/features/ShowOnlineHelp.ts deleted file mode 100644 index 00dde83045..0000000000 --- a/src/features/ShowOnlineHelp.ts +++ /dev/null @@ -1,42 +0,0 @@ -/*--------------------------------------------------------- - * Copyright (C) Microsoft Corporation. All rights reserved. - *--------------------------------------------------------*/ - -import vscode = require("vscode"); -import { LanguageClient, NotificationType, RequestType } from "vscode-languageclient"; -import { IFeature } from "../feature"; - -export const ShowOnlineHelpRequestType = - new RequestType("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; - - const selection = editor.selection; - const doc = editor.document; - const cwr = doc.getWordRangeAtPosition(selection.active); - const text = doc.getText(cwr); - - this.languageClient.sendRequest(ShowOnlineHelpRequestType, text); - }); - } - - public dispose() { - this.command.dispose(); - } - - public setLanguageClient(languageclient: LanguageClient) { - this.languageClient = languageclient; - } -} diff --git a/src/main.ts b/src/main.ts index 08a541d2ad..8e13b80f52 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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"); From 8593ebf40d000205f4e2f2aa877e68b6d4b7e403 Mon Sep 17 00:00:00 2001 From: corbob Date: Tue, 18 Sep 2018 20:03:22 -0700 Subject: [PATCH 3/4] Remove Dummy command. Cleanup structure. Dummy command was used for testing PSES. --- package.json | 4 ---- src/features/ShowHelp.ts | 28 ++-------------------------- 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index ea353cc9a0..1708ad220e 100644 --- a/package.json +++ b/package.json @@ -95,10 +95,6 @@ "command": "PowerShell.ShowHelp", "title": "Get Help for Command", "category": "PowerShell" - },{ - "command": "PowerShell.ShowOnlineHelp", - "title": "Dummy command. Shouldn't be released...", - "category": "PowerShell" }, { "command": "PowerShell.RunSelection", diff --git a/src/features/ShowHelp.ts b/src/features/ShowHelp.ts index 5959eb3c09..4746552c48 100644 --- a/src/features/ShowHelp.ts +++ b/src/features/ShowHelp.ts @@ -6,38 +6,18 @@ import vscode = require("vscode"); import { LanguageClient, NotificationType, RequestType } from "vscode-languageclient"; import { IFeature } from "../feature"; +// TODO: remove ShowOnlineHelpRequest in v2 export const ShowOnlineHelpRequestType = new RequestType("powerShell/showOnlineHelp"); - // I think we can take out the ShowOnlineHelpRequestType... I don't think we actually send it... export const ShowHelpRequestType = new RequestType("powerShell/showHelp"); -export class ShowHelpFeature implements IFeature { +export class ShowHelpFeature implements IFeature { private command: vscode.Disposable; private deprecatedCommand: vscode.Disposable; - // TODO: Remove Dummy command before merge. - // Dummy command is used to test out the write-warning in PSES - // when you send powerShell/showOnlineHelp instead of powerShell/showHelp. - private dummyCommand: vscode.Disposable; private languageClient: LanguageClient; constructor() { - // TODO: Remove this before merge. - this.dummyCommand = vscode.commands.registerCommand("PowerShell.ShowOnlineHelp", () => { - 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.command = vscode.commands.registerCommand("PowerShell.ShowHelp", () => { if (this.languageClient === undefined) { // TODO: Log error message @@ -45,7 +25,6 @@ export class ShowHelpFeature implements IFeature { } const editor = vscode.window.activeTextEditor; - const selection = editor.selection; const doc = editor.document; const cwr = doc.getWordRangeAtPosition(selection.active); @@ -63,9 +42,6 @@ export class ShowHelpFeature implements IFeature { public dispose() { this.command.dispose(); this.deprecatedCommand.dispose(); - // TODO: Remove this dummyCommand too... - // Don't forget the one in package.json - this.dummyCommand.dispose(); } public setLanguageClient(languageclient: LanguageClient) { From 9b3ece5530aa7db5e5acbe14064549d9dd0707b6 Mon Sep 17 00:00:00 2001 From: corbob Date: Thu, 20 Sep 2018 19:40:31 -0700 Subject: [PATCH 4/4] Remove showOnlineHelp requestType as it's not used. Stylistic cleanup. --- package.json | 2 +- src/features/ShowHelp.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 1708ad220e..61f20bacb0 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ }, { "command": "PowerShell.OnlineHelp", - "title": "Get Online Help for Command(Deprecated)", + "title": "Get Online Help for Command (Deprecated)", "category": "PowerShell" }, { diff --git a/src/features/ShowHelp.ts b/src/features/ShowHelp.ts index 4746552c48..0c877740bc 100644 --- a/src/features/ShowHelp.ts +++ b/src/features/ShowHelp.ts @@ -6,9 +6,6 @@ import vscode = require("vscode"); import { LanguageClient, NotificationType, RequestType } from "vscode-languageclient"; import { IFeature } from "../feature"; -// TODO: remove ShowOnlineHelpRequest in v2 -export const ShowOnlineHelpRequestType = - new RequestType("powerShell/showOnlineHelp"); export const ShowHelpRequestType = new RequestType("powerShell/showHelp"); @@ -32,6 +29,7 @@ export class ShowHelpFeature implements IFeature { 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);