From b5be58c73b07cc13a8f30d58f278081aaab1a5b1 Mon Sep 17 00:00:00 2001 From: dfinke Date: Fri, 20 Nov 2015 18:10:50 -0500 Subject: [PATCH] Resolved conflict --- package.json | 20 ++++++++++++++++++++ src/features/ShowOnlineHelp.ts | 5 +++++ src/main.ts | 19 +++++++++++++++++-- 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 src/features/ShowOnlineHelp.ts diff --git a/package.json b/package.json index 2ba9fc67f4..d639df90f6 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,26 @@ "compile": "node ./node_modules/vscode/bin/compile -watch -p ./" }, "contributes": { + "keybindings": [{ + "command": "PowerShell.OnlineHelp", + "key": "ctrl+f1", + "when": "editorTextFocus" + }], + "commands": [{ + "command": "PowerShell.OnlineHelp", + "title": "Get online help for command", + "category": "PowerShell" + }], + "languages": [{ + "id": "PowerShell", + "extensions": [ ".ps1", ".psm1", ".psd1", ".pssc", ".psrc" ], + "aliases": [ "PowerShell", "powershell", "ps", "ps1" ] + }], + "grammars": [{ + "language": "PowerShell", + "scopeName": "source.powershell", + "path": "./syntaxes/PowerShell.tmLanguage" + }], "snippets": [ { "language": "powershell", diff --git a/src/features/ShowOnlineHelp.ts b/src/features/ShowOnlineHelp.ts new file mode 100644 index 0000000000..c898818b67 --- /dev/null +++ b/src/features/ShowOnlineHelp.ts @@ -0,0 +1,5 @@ +import { RequestType, NotificationType, ResponseError } from 'vscode-jsonrpc'; + +export namespace ShowOnlineHelpRequest { + export const type: RequestType = { get method() { return 'showonlinehelp'; } }; +} \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 4ffe4a9edd..bdc761a33f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,11 +9,14 @@ import vscode = require('vscode'); import configuration = require('./features/configuration'); import { LanguageClient, LanguageClientOptions, Executable } from 'vscode-languageclient'; +import { RequestType, NotificationType, ResponseError } from 'vscode-jsonrpc'; +import powerShellMessage = require('./features/ShowOnlineHelp'); + export function activate(context: vscode.ExtensionContext): void { var PowerShellLanguageId = 'PowerShell'; - vscode.languages.setLanguageConfiguration(PowerShellLanguageId, + vscode.languages.setLanguageConfiguration(PowerShellLanguageId, { wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\=\+\[\{\]\}\\\|\;\'\"\,\.\<\>\/\?\s]+)/g, @@ -81,7 +84,19 @@ export function activate(context: vscode.ExtensionContext): void { serverOptions, clientOptions); - client.start(); + client.start(); + + var disposable = vscode.commands.registerCommand('PowerShell.OnlineHelp', () => { + + const editor = vscode.window.activeTextEditor; + + var selection = editor.selection; + var doc = editor.document; + var cwr = doc.getWordRangeAtPosition(selection.active) + var text = doc.getText(cwr); + + client.sendRequest(powerShellMessage.ShowOnlineHelpRequest.type, text); + }); } function resolveLanguageServerPath() : string {