From 5a18734338518dbb749ec89a261dffc296a979dc Mon Sep 17 00:00:00 2001
From: Aleksey Kladov <aleksey.kladov@gmail.com>
Date: Fri, 26 Jun 2020 17:28:04 +0200
Subject: Fix config switching

---
 crates/rust-analyzer/src/reload.rs | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index a1850b286..ec71f8b29 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -1,5 +1,5 @@
 //! Project loading & configuration updates
-use std::sync::Arc;
+use std::{mem, sync::Arc};
 
 use crossbeam_channel::unbounded;
 use flycheck::FlycheckHandle;
@@ -14,12 +14,14 @@ use crate::{
 };
 
 impl GlobalState {
-    pub(crate) fn update_configuration(&mut self, new_config: Config) {
-        self.analysis_host.update_lru_capacity(new_config.lru_capacity);
-        if new_config.flycheck != self.config.flycheck {
+    pub(crate) fn update_configuration(&mut self, config: Config) {
+        let old_config = mem::replace(&mut self.config, config);
+        if self.config.lru_capacity != old_config.lru_capacity {
+            self.analysis_host.update_lru_capacity(old_config.lru_capacity);
+        }
+        if self.config.flycheck != old_config.flycheck {
             self.reload_flycheck();
         }
-        self.config = new_config;
     }
     pub(crate) fn reload(&mut self) {
         let workspaces = {
-- 
cgit v1.2.3