diff options
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/config.ts | 70 | ||||
-rw-r--r-- | editors/code/src/server.ts | 1 |
2 files changed, 58 insertions, 13 deletions
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 2d3b6a54e..6d709f7a8 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: false, | ||
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,7 @@ 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 = 'Changing enhanced typing setting requires a reload'; |
78 | vscode.window | ||
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; | 92 | this.prevEnhancedTyping = this.enableEnhancedTyping; |
91 | } | 93 | } |
92 | 94 | ||
@@ -153,5 +155,47 @@ export class Config { | |||
153 | if (config.has('withSysroot')) { | 155 | if (config.has('withSysroot')) { |
154 | this.withSysroot = config.get('withSysroot') || false; | 156 | this.withSysroot = config.get('withSysroot') || false; |
155 | } | 157 | } |
158 | |||
159 | if (config.has('cargoFeatures.noDefaultFeatures')) { | ||
160 | this.cargoFeatures.noDefaultFeatures = config.get( | ||
161 | 'cargoFeatures.noDefaultFeatures', | ||
162 | false, | ||
163 | ); | ||
164 | } | ||
165 | if (config.has('cargoFeatures.allFeatures')) { | ||
166 | this.cargoFeatures.allFeatures = config.get( | ||
167 | 'cargoFeatures.allFeatures', | ||
168 | false, | ||
169 | ); | ||
170 | } | ||
171 | if (config.has('cargoFeatures.features')) { | ||
172 | this.cargoFeatures.features = config.get( | ||
173 | 'cargoFeatures.features', | ||
174 | [], | ||
175 | ); | ||
176 | } | ||
177 | |||
178 | if (this.prevCargoFeatures !== null && ( | ||
179 | this.cargoFeatures.allFeatures !== this.prevCargoFeatures.allFeatures || | ||
180 | this.cargoFeatures.noDefaultFeatures !== this.prevCargoFeatures.noDefaultFeatures || | ||
181 | this.cargoFeatures.features.length !== this.prevCargoFeatures.features.length || | ||
182 | this.cargoFeatures.features.some((v, i) => v !== this.prevCargoFeatures!.features[i]) | ||
183 | )) { | ||
184 | requireReloadMessage = 'Changing cargo features requires a reload'; | ||
185 | } | ||
186 | this.prevCargoFeatures = { ...this.cargoFeatures }; | ||
187 | |||
188 | if (requireReloadMessage !== null) { | ||
189 | const reloadAction = 'Reload now'; | ||
190 | vscode.window | ||
191 | .showInformationMessage(requireReloadMessage, reloadAction) | ||
192 | .then(selectedAction => { | ||
193 | if (selectedAction === reloadAction) { | ||
194 | vscode.commands.executeCommand( | ||
195 | 'workbench.action.reloadWindow', | ||
196 | ); | ||
197 | } | ||
198 | }); | ||
199 | } | ||
156 | } | 200 | } |
157 | } | 201 | } |
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 | }; |