diff options
author | Omer Ben-Amram <[email protected]> | 2019-12-14 15:29:30 +0000 |
---|---|---|
committer | Omer Ben-Amram <[email protected]> | 2019-12-14 15:29:30 +0000 |
commit | 5e4e713fc9c201852fc5fbafd57e5b9243149a78 (patch) | |
tree | 996b679a9ae1d07be1edd9eb04e93d433c6524a3 /editors/code/src | |
parent | 083010f6339e558184f06ce76a18e1ad0b0ee936 (diff) | |
parent | 77db6177658b32f69ad7ebfdef96c1b3b2893fdd (diff) |
Merge branch 'refs/heads/master' into feature/granular-scopes
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/config.ts | 77 | ||||
-rw-r--r-- | editors/code/src/server.ts | 1 |
2 files changed, 65 insertions, 13 deletions
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 2d3b6a54e..defdfeb9c 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts | |||
@@ -15,6 +15,12 @@ export interface CargoWatchOptions { | |||
15 | ignore: string[]; | 15 | ignore: string[]; |
16 | } | 16 | } |
17 | 17 | ||
18 | export interface CargoFeatures { | ||
19 | noDefaultFeatures: boolean; | ||
20 | allFeatures: boolean; | ||
21 | features: string[]; | ||
22 | } | ||
23 | |||
18 | export class Config { | 24 | export class Config { |
19 | public highlightingOn = true; | 25 | public highlightingOn = true; |
20 | public rainbowHighlightingOn = false; | 26 | public rainbowHighlightingOn = false; |
@@ -35,8 +41,14 @@ export class Config { | |||
35 | command: '', | 41 | command: '', |
36 | ignore: [], | 42 | ignore: [], |
37 | }; | 43 | }; |
44 | public cargoFeatures: CargoFeatures = { | ||
45 | noDefaultFeatures: false, | ||
46 | allFeatures: true, | ||
47 | features: [], | ||
48 | }; | ||
38 | 49 | ||
39 | private prevEnhancedTyping: null | boolean = null; | 50 | private prevEnhancedTyping: null | boolean = null; |
51 | private prevCargoFeatures: null | CargoFeatures = null; | ||
40 | 52 | ||
41 | constructor() { | 53 | constructor() { |
42 | vscode.workspace.onDidChangeConfiguration(_ => | 54 | vscode.workspace.onDidChangeConfiguration(_ => |
@@ -47,6 +59,8 @@ export class Config { | |||
47 | 59 | ||
48 | public userConfigChanged() { | 60 | public userConfigChanged() { |
49 | const config = vscode.workspace.getConfiguration('rust-analyzer'); | 61 | const config = vscode.workspace.getConfiguration('rust-analyzer'); |
62 | let requireReloadMessage = null; | ||
63 | |||
50 | if (config.has('highlightingOn')) { | 64 | if (config.has('highlightingOn')) { |
51 | this.highlightingOn = config.get('highlightingOn') as boolean; | 65 | this.highlightingOn = config.get('highlightingOn') as boolean; |
52 | } | 66 | } |
@@ -74,19 +88,8 @@ export class Config { | |||
74 | } | 88 | } |
75 | 89 | ||
76 | if (this.prevEnhancedTyping !== this.enableEnhancedTyping) { | 90 | if (this.prevEnhancedTyping !== this.enableEnhancedTyping) { |
77 | const reloadAction = 'Reload now'; | 91 | requireReloadMessage = |
78 | vscode.window | 92 | 'Changing enhanced typing setting requires a reload'; |
79 | .showInformationMessage( | ||
80 | 'Changing enhanced typing setting requires a reload', | ||
81 | reloadAction, | ||
82 | ) | ||
83 | .then(selectedAction => { | ||
84 | if (selectedAction === reloadAction) { | ||
85 | vscode.commands.executeCommand( | ||
86 | 'workbench.action.reloadWindow', | ||
87 | ); | ||
88 | } | ||
89 | }); | ||
90 | this.prevEnhancedTyping = this.enableEnhancedTyping; | 93 | this.prevEnhancedTyping = this.enableEnhancedTyping; |
91 | } | 94 | } |
92 | 95 | ||
@@ -153,5 +156,53 @@ export class Config { | |||
153 | if (config.has('withSysroot')) { | 156 | if (config.has('withSysroot')) { |
154 | this.withSysroot = config.get('withSysroot') || false; | 157 | this.withSysroot = config.get('withSysroot') || false; |
155 | } | 158 | } |
159 | |||
160 | if (config.has('cargoFeatures.noDefaultFeatures')) { | ||
161 | this.cargoFeatures.noDefaultFeatures = config.get( | ||
162 | 'cargoFeatures.noDefaultFeatures', | ||
163 | false, | ||
164 | ); | ||
165 | } | ||
166 | if (config.has('cargoFeatures.allFeatures')) { | ||
167 | this.cargoFeatures.allFeatures = config.get( | ||
168 | 'cargoFeatures.allFeatures', | ||
169 | true, | ||
170 | ); | ||
171 | } | ||
172 | if (config.has('cargoFeatures.features')) { | ||
173 | this.cargoFeatures.features = config.get( | ||
174 | 'cargoFeatures.features', | ||
175 | [], | ||
176 | ); | ||
177 | } | ||
178 | |||
179 | if ( | ||
180 | this.prevCargoFeatures !== null && | ||
181 | (this.cargoFeatures.allFeatures !== | ||
182 | this.prevCargoFeatures.allFeatures || | ||
183 | this.cargoFeatures.noDefaultFeatures !== | ||
184 | this.prevCargoFeatures.noDefaultFeatures || | ||
185 | this.cargoFeatures.features.length !== | ||
186 | this.prevCargoFeatures.features.length || | ||
187 | this.cargoFeatures.features.some( | ||
188 | (v, i) => v !== this.prevCargoFeatures!.features[i], | ||
189 | )) | ||
190 | ) { | ||
191 | requireReloadMessage = 'Changing cargo features requires a reload'; | ||
192 | } | ||
193 | this.prevCargoFeatures = { ...this.cargoFeatures }; | ||
194 | |||
195 | if (requireReloadMessage !== null) { | ||
196 | const reloadAction = 'Reload now'; | ||
197 | vscode.window | ||
198 | .showInformationMessage(requireReloadMessage, reloadAction) | ||
199 | .then(selectedAction => { | ||
200 | if (selectedAction === reloadAction) { | ||
201 | vscode.commands.executeCommand( | ||
202 | 'workbench.action.reloadWindow', | ||
203 | ); | ||
204 | } | ||
205 | }); | ||
206 | } | ||
156 | } | 207 | } |
157 | } | 208 | } |
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts index 2fe45f1ed..5ace1d0fa 100644 --- a/editors/code/src/server.ts +++ b/editors/code/src/server.ts | |||
@@ -59,6 +59,7 @@ export class Server { | |||
59 | useClientWatching: Server.config.useClientWatching, | 59 | useClientWatching: Server.config.useClientWatching, |
60 | featureFlags: Server.config.featureFlags, | 60 | featureFlags: Server.config.featureFlags, |
61 | withSysroot: Server.config.withSysroot, | 61 | withSysroot: Server.config.withSysroot, |
62 | cargoFeatures: Server.config.cargoFeatures, | ||
62 | }, | 63 | }, |
63 | traceOutputChannel, | 64 | traceOutputChannel, |
64 | }; | 65 | }; |