From e04b8241eda7a9eb89a6a2db5815e15e886286b9 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 2 Jul 2019 00:18:12 -0700 Subject: [PATCH] Move to evaluate LSP message --- src/client/extension.ts | 11 +++++++---- src/client/messages.ts | 13 +++++++++++++ src/client/process.ts | 7 ++++--- 3 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 src/client/messages.ts diff --git a/src/client/extension.ts b/src/client/extension.ts index 63730c1..af73b88 100644 --- a/src/client/extension.ts +++ b/src/client/extension.ts @@ -11,6 +11,7 @@ import { fileURLToPath, sleep } from './utils' import { getDefaultPowerShellPath, getPlatformDetails } from './platform'; import settings = require("./settings"); import * as process from './process'; +import { EvaluateRequestType } from "./messages"; async function getCurrentSelection(mode: string) { let doc = await workspace.document @@ -80,10 +81,12 @@ function startREPLProc(context: ExtensionContext, config: settings.ISettings, pw return } - for(let line of await getCurrentSelection(mode)) - { - await proc.eval(line) - } + // TODO: move to workspace.getCurrentSelection when we get an answer: + // https://github.com/neoclide/coc.nvim/issues/933 + const content = (await getCurrentSelection(mode)).join("\n"); + client.sendRequest(EvaluateRequestType, { + expression: content, + }); await proc.scrollToBottom() } diff --git a/src/client/messages.ts b/src/client/messages.ts new file mode 100644 index 0000000..06ef170 --- /dev/null +++ b/src/client/messages.ts @@ -0,0 +1,13 @@ +/* -------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * ------------------------------------------------------------------------------------------ */ + +// The collection of custom messages that coc-powershell will send to/receive from PowerShell Editor Services + +import { RequestType } from 'vscode-jsonrpc'; + +export const EvaluateRequestType = new RequestType("evaluate"); +export interface IEvaluateRequestArguments { + expression: string; +} diff --git a/src/client/process.ts b/src/client/process.ts index 1acf798..13b64ef 100644 --- a/src/client/process.ts +++ b/src/client/process.ts @@ -1,6 +1,7 @@ -/*--------------------------------------------------------- - * Copyright (C) Microsoft Corporation. All rights reserved. - *--------------------------------------------------------*/ +/* -------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * ------------------------------------------------------------------------------------------ */ import cp = require("child_process"); import fs = require("fs");