Merge #1696
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:
commit
83413cc9ef
1 changed files with 9 additions and 1 deletions
|
@ -1,9 +1,17 @@
|
||||||
|
import { homedir } from 'os';
|
||||||
import * as lc from 'vscode-languageclient';
|
import * as lc from 'vscode-languageclient';
|
||||||
|
|
||||||
import { window, workspace } from 'vscode';
|
import { window, workspace } from 'vscode';
|
||||||
import { Config } from './config';
|
import { Config } from './config';
|
||||||
import { Highlighter } from './highlighting';
|
import { Highlighter } from './highlighting';
|
||||||
|
|
||||||
|
function expandPathResolving(path: string) {
|
||||||
|
if (path.startsWith('~/')) {
|
||||||
|
return path.replace('~', homedir());
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
export class Server {
|
export class Server {
|
||||||
public static highlighter = new Highlighter();
|
public static highlighter = new Highlighter();
|
||||||
public static config = new Config();
|
public static config = new Config();
|
||||||
|
@ -20,7 +28,7 @@ export class Server {
|
||||||
}
|
}
|
||||||
|
|
||||||
const run: lc.Executable = {
|
const run: lc.Executable = {
|
||||||
command: this.config.raLspServerPath,
|
command: expandPathResolving(this.config.raLspServerPath),
|
||||||
options: { cwd: folder }
|
options: { cwd: folder }
|
||||||
};
|
};
|
||||||
const serverOptions: lc.ServerOptions = {
|
const serverOptions: lc.ServerOptions = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue