From 7185c594fe1b6c282c432c1fbb57e8e6e23421ed Mon Sep 17 00:00:00 2001 From: Lucas Spits Date: Mon, 11 Mar 2019 20:38:46 +0100 Subject: Retrieve current directory from workspaces --- editors/code/src/server.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts index 50461b0c6..30ab874ab 100644 --- a/editors/code/src/server.ts +++ b/editors/code/src/server.ts @@ -1,6 +1,6 @@ import * as lc from 'vscode-languageclient'; -import { window } from 'vscode'; +import { window, workspace } from 'vscode'; import { Config } from './config'; import { Highlighter } from './highlighting'; @@ -12,9 +12,25 @@ export class Server { public static start( notificationHandlers: Iterable<[string, lc.GenericNotificationHandler]> ) { + + // '.' Is the fallback if no folder is open + // 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. + let folder: string = '.'; + if (workspace.workspaceFolders !== undefined) { + + folder = workspace + .workspaceFolders[0].uri.fsPath + .toString(); + + if (workspace.workspaceFolders.length > 1) { + // Tell the user that we do not support multi-root workspaces yet + window.showWarningMessage("Multi-root workspaces are not currently supported"); + } + } + const run: lc.Executable = { command: this.config.raLspServerPath, - options: { cwd: '.' } + options: { cwd: folder } }; const serverOptions: lc.ServerOptions = { run, -- cgit v1.2.3 From 915c079e26a8da890d03b0a4a0960b06d45e66e2 Mon Sep 17 00:00:00 2001 From: Lucas Spits Date: Mon, 11 Mar 2019 20:53:56 +0100 Subject: Fix typescript linting errors --- editors/code/src/server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts index 30ab874ab..b3a874b38 100644 --- a/editors/code/src/server.ts +++ b/editors/code/src/server.ts @@ -24,7 +24,7 @@ export class Server { if (workspace.workspaceFolders.length > 1) { // Tell the user that we do not support multi-root workspaces yet - window.showWarningMessage("Multi-root workspaces are not currently supported"); + window.showWarningMessage('Multi-root workspaces are not currently supported'); } } -- cgit v1.2.3 From 9fe3b36bdae52dabecc3989161162fc6d2a3dccb Mon Sep 17 00:00:00 2001 From: Lucas Spits Date: Mon, 11 Mar 2019 21:22:54 +0100 Subject: Applied code style of ``npm run fix`` --- editors/code/src/server.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts index b3a874b38..f319f148a 100644 --- a/editors/code/src/server.ts +++ b/editors/code/src/server.ts @@ -12,19 +12,17 @@ export class Server { public static start( notificationHandlers: Iterable<[string, lc.GenericNotificationHandler]> ) { - // '.' Is the fallback if no folder is open // 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. let folder: string = '.'; if (workspace.workspaceFolders !== undefined) { + folder = workspace.workspaceFolders[0].uri.fsPath.toString(); - folder = workspace - .workspaceFolders[0].uri.fsPath - .toString(); - if (workspace.workspaceFolders.length > 1) { // Tell the user that we do not support multi-root workspaces yet - window.showWarningMessage('Multi-root workspaces are not currently supported'); + window.showWarningMessage( + 'Multi-root workspaces are not currently supported' + ); } } -- cgit v1.2.3