Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion x-pack/plugins/code/server/lsp/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
*/
import EventEmitter from 'events';
import * as net from 'net';
import { fileURLToPath } from 'url';
import {
createMessageConnection,
MessageConnection,
SocketMessageReader,
SocketMessageWriter,
} from 'vscode-jsonrpc';

import { RequestMessage, ResponseMessage } from 'vscode-jsonrpc/lib/messages';

import {
Expand Down Expand Up @@ -111,6 +111,7 @@ export class LanguageServerProxy implements ILanguageServerHandler {
workspaceFolders,
rootUri,
capabilities: clientCapabilities,
rootPath: fileURLToPath(rootUri),
};
return await clientConn
.sendRequest(
Expand Down
11 changes: 7 additions & 4 deletions x-pack/plugins/code/server/lsp/request_expander.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import fs from 'fs';
import mkdirp from 'mkdirp';
import rimraf from 'rimraf';
import sinon from 'sinon';
import { pathToFileURL } from 'url';

import { ServerOptions } from '../server_options';
import { LanguageServerProxy } from './proxy';
import { InitializingError, RequestExpander } from './request_expander';
Expand Down Expand Up @@ -117,6 +119,7 @@ test('be able to open multiple workspace', async () => {
params: [],
workspacePath: '/tmp/test/workspace/1',
};

const request2 = {
method: 'request2',
params: [],
Expand All @@ -131,7 +134,7 @@ test('be able to open multiple workspace', async () => {
proxyStub.initialize.calledOnceWith({}, [
{
name: request1.workspacePath,
uri: `file://${request1.workspacePath}`,
uri: pathToFileURL(request1.workspacePath).href,
},
])
).toBeTruthy();
Expand All @@ -143,7 +146,7 @@ test('be able to open multiple workspace', async () => {
added: [
{
name: request2.workspacePath,
uri: `file://${request2.workspacePath}`,
uri: pathToFileURL(request2.workspacePath).href,
},
],
removed: [],
Expand Down Expand Up @@ -187,13 +190,13 @@ test('be able to swap workspace', async () => {
added: [
{
name: request2.workspacePath,
uri: `file://${request2.workspacePath}`,
uri: pathToFileURL(request2.workspacePath).href,
},
],
removed: [
{
name: request1.workspacePath,
uri: `file://${request1.workspacePath}`,
uri: pathToFileURL(request1.workspacePath).href,
},
],
},
Expand Down
11 changes: 7 additions & 4 deletions x-pack/plugins/code/server/lsp/request_expander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@

import fs from 'fs';
import path from 'path';
import { pathToFileURL } from 'url';

import { ResponseError, ResponseMessage } from 'vscode-jsonrpc/lib/messages';
import { DidChangeWorkspaceFoldersParams, InitializeResult } from 'vscode-languageserver-protocol';

import { ServerNotInitialized } from '../../common/lsp_error_codes';
import { LspRequest } from '../../model';
import { ServerOptions } from '../server_options';
Expand Down Expand Up @@ -93,7 +96,7 @@ export class RequestExpander implements ILanguageServerHandler {
removed: [
{
name: workspacePath!,
uri: `file://${workspacePath}`,
uri: pathToFileURL(workspacePath).href,
},
],
added: [],
Expand Down Expand Up @@ -148,7 +151,7 @@ export class RequestExpander implements ILanguageServerHandler {
[
{
name: workspacePath,
uri: `file://${workspacePath}`,
uri: pathToFileURL(workspacePath).href,
},
],
this.initialOptions
Expand Down Expand Up @@ -227,7 +230,7 @@ export class RequestExpander implements ILanguageServerHandler {
added: [
{
name: workspacePath!,
uri: `file://${workspacePath}`,
uri: pathToFileURL(workspacePath).href,
},
],
removed: [],
Expand All @@ -247,7 +250,7 @@ export class RequestExpander implements ILanguageServerHandler {
if (oldestWorkspace) {
params.event.removed.push({
name: oldestWorkspace,
uri: `file://${oldestWorkspace}`,
uri: pathToFileURL(oldestWorkspace).href,
});
this.removeWorkspace(oldestWorkspace);
}
Expand Down