diff options
author | Seivan Heidari <[email protected]> | 2019-12-23 14:35:31 +0000 |
---|---|---|
committer | Seivan Heidari <[email protected]> | 2019-12-23 14:35:31 +0000 |
commit | b21d9337d9200e2cfdc90b386591c72c302dc03e (patch) | |
tree | f81f5c08f821115cee26fa4d3ceaae88c7807fd5 /editors/code/src/config.ts | |
parent | 18a0937585b836ec5ed054b9ae48e0156ab6d9ef (diff) | |
parent | ce07a2daa9e53aa86a769f8641b14c2878444fbc (diff) |
Merge branch 'master' into feature/themes
Diffstat (limited to 'editors/code/src/config.ts')
-rw-r--r-- | editors/code/src/config.ts | 113 |
1 files changed, 89 insertions, 24 deletions
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 4cedbea46..c06dddb1c 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts | |||
@@ -14,6 +14,13 @@ export interface CargoWatchOptions { | |||
14 | command: string; | 14 | command: string; |
15 | trace: CargoWatchTraceOptions; | 15 | trace: CargoWatchTraceOptions; |
16 | ignore: string[]; | 16 | ignore: string[]; |
17 | allTargets: boolean; | ||
18 | } | ||
19 | |||
20 | export interface CargoFeatures { | ||
21 | noDefaultFeatures: boolean; | ||
22 | allFeatures: boolean; | ||
23 | features: string[]; | ||
17 | } | 24 | } |
18 | 25 | ||
19 | export class Config { | 26 | export class Config { |
@@ -25,21 +32,30 @@ export class Config { | |||
25 | public displayInlayHints = true; | 32 | public displayInlayHints = true; |
26 | public maxInlayHintLength: null | number = null; | 33 | public maxInlayHintLength: null | number = null; |
27 | public excludeGlobs = []; | 34 | public excludeGlobs = []; |
28 | public useClientWatching = false; | 35 | public useClientWatching = true; |
29 | public featureFlags = {}; | 36 | public featureFlags = {}; |
37 | // for internal use | ||
38 | public withSysroot: null | boolean = null; | ||
30 | public cargoWatchOptions: CargoWatchOptions = { | 39 | public cargoWatchOptions: CargoWatchOptions = { |
31 | enableOnStartup: 'ask', | 40 | enableOnStartup: 'ask', |
32 | trace: 'off', | 41 | trace: 'off', |
33 | arguments: '', | 42 | arguments: '', |
34 | command: '', | 43 | command: '', |
35 | ignore: [] | 44 | ignore: [], |
45 | allTargets: true, | ||
46 | }; | ||
47 | public cargoFeatures: CargoFeatures = { | ||
48 | noDefaultFeatures: false, | ||
49 | allFeatures: true, | ||
50 | features: [], | ||
36 | }; | 51 | }; |
37 | 52 | ||
38 | private prevEnhancedTyping: null | boolean = null; | 53 | private prevEnhancedTyping: null | boolean = null; |
54 | private prevCargoFeatures: null | CargoFeatures = null; | ||
39 | 55 | ||
40 | constructor() { | 56 | constructor() { |
41 | vscode.workspace.onDidChangeConfiguration(_ => | 57 | vscode.workspace.onDidChangeConfiguration(_ => |
42 | this.userConfigChanged() | 58 | this.userConfigChanged(), |
43 | ); | 59 | ); |
44 | this.userConfigChanged(); | 60 | this.userConfigChanged(); |
45 | } | 61 | } |
@@ -49,6 +65,8 @@ export class Config { | |||
49 | 65 | ||
50 | Server.highlighter.removeHighlights(); | 66 | Server.highlighter.removeHighlights(); |
51 | 67 | ||
68 | let requireReloadMessage = null; | ||
69 | |||
52 | if (config.has('highlightingOn')) { | 70 | if (config.has('highlightingOn')) { |
53 | this.highlightingOn = config.get('highlightingOn') as boolean; | 71 | this.highlightingOn = config.get('highlightingOn') as boolean; |
54 | if (this.highlightingOn) { | 72 | if (this.highlightingOn) { |
@@ -59,13 +77,13 @@ export class Config { | |||
59 | 77 | ||
60 | if (config.has('rainbowHighlightingOn')) { | 78 | if (config.has('rainbowHighlightingOn')) { |
61 | this.rainbowHighlightingOn = config.get( | 79 | this.rainbowHighlightingOn = config.get( |
62 | 'rainbowHighlightingOn' | 80 | 'rainbowHighlightingOn', |
63 | ) as boolean; | 81 | ) as boolean; |
64 | } | 82 | } |
65 | 83 | ||
66 | if (config.has('enableEnhancedTyping')) { | 84 | if (config.has('enableEnhancedTyping')) { |
67 | this.enableEnhancedTyping = config.get( | 85 | this.enableEnhancedTyping = config.get( |
68 | 'enableEnhancedTyping' | 86 | 'enableEnhancedTyping', |
69 | ) as boolean; | 87 | ) as boolean; |
70 | 88 | ||
71 | if (this.prevEnhancedTyping === null) { | 89 | if (this.prevEnhancedTyping === null) { |
@@ -76,19 +94,8 @@ export class Config { | |||
76 | } | 94 | } |
77 | 95 | ||
78 | if (this.prevEnhancedTyping !== this.enableEnhancedTyping) { | 96 | if (this.prevEnhancedTyping !== this.enableEnhancedTyping) { |
79 | const reloadAction = 'Reload now'; | 97 | requireReloadMessage = |
80 | vscode.window | 98 | 'Changing enhanced typing setting requires a reload'; |
81 | .showInformationMessage( | ||
82 | 'Changing enhanced typing setting requires a reload', | ||
83 | reloadAction | ||
84 | ) | ||
85 | .then(selectedAction => { | ||
86 | if (selectedAction === reloadAction) { | ||
87 | vscode.commands.executeCommand( | ||
88 | 'workbench.action.reloadWindow' | ||
89 | ); | ||
90 | } | ||
91 | }); | ||
92 | this.prevEnhancedTyping = this.enableEnhancedTyping; | 99 | this.prevEnhancedTyping = this.enableEnhancedTyping; |
93 | } | 100 | } |
94 | 101 | ||
@@ -106,28 +113,35 @@ export class Config { | |||
106 | if (config.has('trace.cargo-watch')) { | 113 | if (config.has('trace.cargo-watch')) { |
107 | this.cargoWatchOptions.trace = config.get<CargoWatchTraceOptions>( | 114 | this.cargoWatchOptions.trace = config.get<CargoWatchTraceOptions>( |
108 | 'trace.cargo-watch', | 115 | 'trace.cargo-watch', |
109 | 'off' | 116 | 'off', |
110 | ); | 117 | ); |
111 | } | 118 | } |
112 | 119 | ||
113 | if (config.has('cargo-watch.arguments')) { | 120 | if (config.has('cargo-watch.arguments')) { |
114 | this.cargoWatchOptions.arguments = config.get<string>( | 121 | this.cargoWatchOptions.arguments = config.get<string>( |
115 | 'cargo-watch.arguments', | 122 | 'cargo-watch.arguments', |
116 | '' | 123 | '', |
117 | ); | 124 | ); |
118 | } | 125 | } |
119 | 126 | ||
120 | if (config.has('cargo-watch.command')) { | 127 | if (config.has('cargo-watch.command')) { |
121 | this.cargoWatchOptions.command = config.get<string>( | 128 | this.cargoWatchOptions.command = config.get<string>( |
122 | 'cargo-watch.command', | 129 | 'cargo-watch.command', |
123 | '' | 130 | '', |
124 | ); | 131 | ); |
125 | } | 132 | } |
126 | 133 | ||
127 | if (config.has('cargo-watch.ignore')) { | 134 | if (config.has('cargo-watch.ignore')) { |
128 | this.cargoWatchOptions.ignore = config.get<string[]>( | 135 | this.cargoWatchOptions.ignore = config.get<string[]>( |
129 | 'cargo-watch.ignore', | 136 | 'cargo-watch.ignore', |
130 | [] | 137 | [], |
138 | ); | ||
139 | } | ||
140 | |||
141 | if (config.has('cargo-watch.allTargets')) { | ||
142 | this.cargoWatchOptions.allTargets = config.get<boolean>( | ||
143 | 'cargo-watch.allTargets', | ||
144 | true, | ||
131 | ); | 145 | ); |
132 | } | 146 | } |
133 | 147 | ||
@@ -140,17 +154,68 @@ export class Config { | |||
140 | } | 154 | } |
141 | if (config.has('maxInlayHintLength')) { | 155 | if (config.has('maxInlayHintLength')) { |
142 | this.maxInlayHintLength = config.get( | 156 | this.maxInlayHintLength = config.get( |
143 | 'maxInlayHintLength' | 157 | 'maxInlayHintLength', |
144 | ) as number; | 158 | ) as number; |
145 | } | 159 | } |
146 | if (config.has('excludeGlobs')) { | 160 | if (config.has('excludeGlobs')) { |
147 | this.excludeGlobs = config.get('excludeGlobs') || []; | 161 | this.excludeGlobs = config.get('excludeGlobs') || []; |
148 | } | 162 | } |
149 | if (config.has('useClientWatching')) { | 163 | if (config.has('useClientWatching')) { |
150 | this.useClientWatching = config.get('useClientWatching') || false; | 164 | this.useClientWatching = config.get('useClientWatching') || true; |
151 | } | 165 | } |
152 | if (config.has('featureFlags')) { | 166 | if (config.has('featureFlags')) { |
153 | this.featureFlags = config.get('featureFlags') || {}; | 167 | this.featureFlags = config.get('featureFlags') || {}; |
154 | } | 168 | } |
169 | if (config.has('withSysroot')) { | ||
170 | this.withSysroot = config.get('withSysroot') || false; | ||
171 | } | ||
172 | |||
173 | if (config.has('cargoFeatures.noDefaultFeatures')) { | ||
174 | this.cargoFeatures.noDefaultFeatures = config.get( | ||
175 | 'cargoFeatures.noDefaultFeatures', | ||
176 | false, | ||
177 | ); | ||
178 | } | ||
179 | if (config.has('cargoFeatures.allFeatures')) { | ||
180 | this.cargoFeatures.allFeatures = config.get( | ||
181 | 'cargoFeatures.allFeatures', | ||
182 | true, | ||
183 | ); | ||
184 | } | ||
185 | if (config.has('cargoFeatures.features')) { | ||
186 | this.cargoFeatures.features = config.get( | ||
187 | 'cargoFeatures.features', | ||
188 | [], | ||
189 | ); | ||
190 | } | ||
191 | |||
192 | if ( | ||
193 | this.prevCargoFeatures !== null && | ||
194 | (this.cargoFeatures.allFeatures !== | ||
195 | this.prevCargoFeatures.allFeatures || | ||
196 | this.cargoFeatures.noDefaultFeatures !== | ||
197 | this.prevCargoFeatures.noDefaultFeatures || | ||
198 | this.cargoFeatures.features.length !== | ||
199 | this.prevCargoFeatures.features.length || | ||
200 | this.cargoFeatures.features.some( | ||
201 | (v, i) => v !== this.prevCargoFeatures!.features[i], | ||
202 | )) | ||
203 | ) { | ||
204 | requireReloadMessage = 'Changing cargo features requires a reload'; | ||
205 | } | ||
206 | this.prevCargoFeatures = { ...this.cargoFeatures }; | ||
207 | |||
208 | if (requireReloadMessage !== null) { | ||
209 | const reloadAction = 'Reload now'; | ||
210 | vscode.window | ||
211 | .showInformationMessage(requireReloadMessage, reloadAction) | ||
212 | .then(selectedAction => { | ||
213 | if (selectedAction === reloadAction) { | ||
214 | vscode.commands.executeCommand( | ||
215 | 'workbench.action.reloadWindow', | ||
216 | ); | ||
217 | } | ||
218 | }); | ||
219 | } | ||
155 | } | 220 | } |
156 | } | 221 | } |