1696: fix #1424 r=matklad a=coderfox

- resolve "~" in raLspServerPath

I think expanding simply `~/` is quite simple as node provides `homedir`, but expanding `~foo/` is difficult as there is no cross-platform approach of reading home directory of another user. So this pull request only resolves `~/` in `raLspServerPath`.

Besides, the source code is arranged in a way hard to write tests. Would anyone provide me with instructions of writing tests for this feature, or no test is required for this feature?

Co-authored-by: xfoxfu <i@xfox.me>
This commit is contained in:
bors[bot] 2019-08-19 08:05:39 +00:00 committed by GitHub
commit 83413cc9ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,9 +1,17 @@
import { homedir } from 'os';
import * as lc from 'vscode-languageclient';
import { window, workspace } from 'vscode';
import { Config } from './config';
import { Highlighter } from './highlighting';
function expandPathResolving(path: string) {
if (path.startsWith('~/')) {
return path.replace('~', homedir());
}
return path;
}
export class Server {
public static highlighter = new Highlighter();
public static config = new Config();
@ -20,7 +28,7 @@ export class Server {
}
const run: lc.Executable = {
command: this.config.raLspServerPath,
command: expandPathResolving(this.config.raLspServerPath),
options: { cwd: folder }
};
const serverOptions: lc.ServerOptions = {