Skip to content

Commit

Permalink
Move to evaluate LSP message
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerLeonhardt committed Jul 2, 2019
1 parent dfc3a99 commit e04b824
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
Expand Down
13 changes: 13 additions & 0 deletions src/client/messages.ts
Original file line number Diff line number Diff line change
@@ -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<IEvaluateRequestArguments, void, void, void>("evaluate");
export interface IEvaluateRequestArguments {
expression: string;
}
7 changes: 4 additions & 3 deletions src/client/process.ts
Original file line number Diff line number Diff line change
@@ -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");
Expand Down

0 comments on commit e04b824

Please sign in to comment.