Pass string instread of WorkspaceFolder

This commit is contained in:
Tim 2020-03-31 10:23:18 +01:00 committed by Tim Hutt
parent 9ef1e9efc6
commit 3eb45b9922
3 changed files with 5 additions and 5 deletions

View file

@ -30,14 +30,14 @@ export function configToServerOptions(config: Config) {
}; };
} }
export async function createClient(config: Config, serverPath: string, workspaceFolder: vscode.WorkspaceFolder): Promise<lc.LanguageClient> { export async function createClient(config: Config, serverPath: string, cwd: string): Promise<lc.LanguageClient> {
// '.' Is the fallback if no folder is open // '.' Is the fallback if no folder is open
// TODO?: Workspace folders support Uri's (eg: file://test.txt). // TODO?: Workspace folders support Uri's (eg: file://test.txt).
// It might be a good idea to test if the uri points to a file. // It might be a good idea to test if the uri points to a file.
const run: lc.Executable = { const run: lc.Executable = {
command: serverPath, command: serverPath,
options: { cwd: workspaceFolder.uri.fsPath }, options: { cwd },
}; };
const serverOptions: lc.ServerOptions = { const serverOptions: lc.ServerOptions = {
run, run,

View file

@ -19,9 +19,9 @@ export class Ctx {
config: Config, config: Config,
extCtx: vscode.ExtensionContext, extCtx: vscode.ExtensionContext,
serverPath: string, serverPath: string,
workspaceFolder: vscode.WorkspaceFolder, cwd: string,
): Promise<Ctx> { ): Promise<Ctx> {
const client = await createClient(config, serverPath, workspaceFolder); const client = await createClient(config, serverPath, cwd);
const res = new Ctx(config, extCtx, client, serverPath); const res = new Ctx(config, extCtx, client, serverPath);
res.pushCleanup(client.start()); res.pushCleanup(client.start());
await client.onReady(); await client.onReady();

View file

@ -53,7 +53,7 @@ export async function activate(context: vscode.ExtensionContext) {
// registers its `onDidChangeDocument` handler before us. // registers its `onDidChangeDocument` handler before us.
// //
// This a horribly, horribly wrong way to deal with this problem. // This a horribly, horribly wrong way to deal with this problem.
ctx = await Ctx.create(config, context, serverPath, workspaceFolder); ctx = await Ctx.create(config, context, serverPath, workspaceFolder.uri.fsPath);
// Commands which invokes manually via command palette, shortcut, etc. // Commands which invokes manually via command palette, shortcut, etc.