|
12 | 12 | //! correct. Instead, we try to provide a best-effort service. Even if the
|
13 | 13 | //! project is currently loading and we don't have a full project model, we
|
14 | 14 | //! still want to respond to various requests.
|
15 |
| -use std::{mem, sync::Arc}; |
| 15 | +use std::{env, mem, sync::Arc}; |
16 | 16 |
|
17 | 17 | use flycheck::{FlycheckConfig, FlycheckHandle};
|
18 | 18 | use hir::db::DefDatabase;
|
@@ -59,11 +59,25 @@ impl GlobalState {
|
59 | 59 | pub(crate) fn update_configuration(&mut self, config: Config) {
|
60 | 60 | let _p = profile::span("GlobalState::update_configuration");
|
61 | 61 | let old_config = mem::replace(&mut self.config, Arc::new(config));
|
| 62 | + let env_changed = self.config.extra_env() != old_config.extra_env(); |
| 63 | + if env_changed { |
| 64 | + for (old_key, old_value) in self.overwritten_env_vars.drain(..) { |
| 65 | + if let Some(old_value) = old_value { |
| 66 | + env::set_var(old_key, old_value); |
| 67 | + } else { |
| 68 | + env::remove_var(old_key); |
| 69 | + } |
| 70 | + } |
| 71 | + for (new_key, new_value) in self.config.extra_env() { |
| 72 | + self.overwritten_env_vars.push((new_key.clone(), std::env::var_os(new_key))); |
| 73 | + std::env::set_var(new_key, new_value); |
| 74 | + } |
| 75 | + } |
62 | 76 | if self.config.lru_capacity() != old_config.lru_capacity() {
|
63 | 77 | self.analysis_host.update_lru_capacity(self.config.lru_capacity());
|
64 | 78 | }
|
65 |
| - if self.config.linked_projects() != old_config.linked_projects() { |
66 |
| - self.fetch_workspaces_queue.request_op("linked projects changed".to_string()) |
| 79 | + if env_changed || self.config.linked_projects() != old_config.linked_projects() { |
| 80 | + self.fetch_workspaces_queue.request_op("env or linked projects changed".to_string()) |
67 | 81 | } else if self.config.flycheck() != old_config.flycheck() {
|
68 | 82 | self.reload_flycheck();
|
69 | 83 | }
|
|
0 commit comments