diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-19 09:05:39 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-08-19 09:05:39 +0100 |
commit | 83413cc9ef73d578f2e42c21f7aa85ef296be8c0 (patch) | |
tree | 12bb8180259d4e9c9cf54c5c42ebf99792fd4f15 /editors/code/src | |
parent | 2bac1bdf174a053f0727e982f0f92d068ef3c208 (diff) | |
parent | d07a85ed7e0ed3baac6e8fc66cd27116056e9810 (diff) |
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 <[email protected]>
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/server.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts index 2b4c25c28..3273d8749 100644 --- a/editors/code/src/server.ts +++ b/editors/code/src/server.ts | |||
@@ -1,9 +1,17 @@ | |||
1 | import { homedir } from 'os'; | ||
1 | import * as lc from 'vscode-languageclient'; | 2 | import * as lc from 'vscode-languageclient'; |
2 | 3 | ||
3 | import { window, workspace } from 'vscode'; | 4 | import { window, workspace } from 'vscode'; |
4 | import { Config } from './config'; | 5 | import { Config } from './config'; |
5 | import { Highlighter } from './highlighting'; | 6 | import { Highlighter } from './highlighting'; |
6 | 7 | ||
8 | function expandPathResolving(path: string) { | ||
9 | if (path.startsWith('~/')) { | ||
10 | return path.replace('~', homedir()); | ||
11 | } | ||
12 | return path; | ||
13 | } | ||
14 | |||
7 | export class Server { | 15 | export class Server { |
8 | public static highlighter = new Highlighter(); | 16 | public static highlighter = new Highlighter(); |
9 | public static config = new Config(); | 17 | public static config = new Config(); |
@@ -20,7 +28,7 @@ export class Server { | |||
20 | } | 28 | } |
21 | 29 | ||
22 | const run: lc.Executable = { | 30 | const run: lc.Executable = { |
23 | command: this.config.raLspServerPath, | 31 | command: expandPathResolving(this.config.raLspServerPath), |
24 | options: { cwd: folder } | 32 | options: { cwd: folder } |
25 | }; | 33 | }; |
26 | const serverOptions: lc.ServerOptions = { | 34 | const serverOptions: lc.ServerOptions = { |