diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_lsp_server/src/cargo_check.rs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/crates/ra_lsp_server/src/cargo_check.rs b/crates/ra_lsp_server/src/cargo_check.rs index dd8c5d407..42e55565f 100644 --- a/crates/ra_lsp_server/src/cargo_check.rs +++ b/crates/ra_lsp_server/src/cargo_check.rs | |||
@@ -33,6 +33,7 @@ pub struct CheckWatcher { | |||
33 | 33 | ||
34 | impl CheckWatcher { | 34 | impl CheckWatcher { |
35 | pub fn new(options: &Options, workspace_root: PathBuf) -> CheckWatcher { | 35 | pub fn new(options: &Options, workspace_root: PathBuf) -> CheckWatcher { |
36 | let check_enabled = options.cargo_check_enable; | ||
36 | let check_command = options.cargo_check_command.clone(); | 37 | let check_command = options.cargo_check_command.clone(); |
37 | let check_args = options.cargo_check_args.clone(); | 38 | let check_args = options.cargo_check_args.clone(); |
38 | let shared = Arc::new(RwLock::new(CheckWatcherSharedState::new())); | 39 | let shared = Arc::new(RwLock::new(CheckWatcherSharedState::new())); |
@@ -41,8 +42,13 @@ impl CheckWatcher { | |||
41 | let (cmd_send, cmd_recv) = unbounded::<CheckCommand>(); | 42 | let (cmd_send, cmd_recv) = unbounded::<CheckCommand>(); |
42 | let shared_ = shared.clone(); | 43 | let shared_ = shared.clone(); |
43 | let handle = std::thread::spawn(move || { | 44 | let handle = std::thread::spawn(move || { |
44 | let mut check = | 45 | let mut check = CheckWatcherState::new( |
45 | CheckWatcherState::new(check_command, check_args, workspace_root, shared_); | 46 | check_enabled, |
47 | check_command, | ||
48 | check_args, | ||
49 | workspace_root, | ||
50 | shared_, | ||
51 | ); | ||
46 | check.run(&task_send, &cmd_recv); | 52 | check.run(&task_send, &cmd_recv); |
47 | }); | 53 | }); |
48 | 54 | ||
@@ -55,6 +61,7 @@ impl CheckWatcher { | |||
55 | } | 61 | } |
56 | 62 | ||
57 | pub struct CheckWatcherState { | 63 | pub struct CheckWatcherState { |
64 | check_enabled: bool, | ||
58 | check_command: Option<String>, | 65 | check_command: Option<String>, |
59 | check_args: Vec<String>, | 66 | check_args: Vec<String>, |
60 | workspace_root: PathBuf, | 67 | workspace_root: PathBuf, |
@@ -142,13 +149,16 @@ pub enum CheckCommand { | |||
142 | 149 | ||
143 | impl CheckWatcherState { | 150 | impl CheckWatcherState { |
144 | pub fn new( | 151 | pub fn new( |
152 | check_enabled: bool, | ||
145 | check_command: Option<String>, | 153 | check_command: Option<String>, |
146 | check_args: Vec<String>, | 154 | check_args: Vec<String>, |
147 | workspace_root: PathBuf, | 155 | workspace_root: PathBuf, |
148 | shared: Arc<RwLock<CheckWatcherSharedState>>, | 156 | shared: Arc<RwLock<CheckWatcherSharedState>>, |
149 | ) -> CheckWatcherState { | 157 | ) -> CheckWatcherState { |
150 | let watcher = WatchThread::new(check_command.as_ref(), &check_args, &workspace_root); | 158 | let watcher = |
159 | WatchThread::new(check_enabled, check_command.as_ref(), &check_args, &workspace_root); | ||
151 | CheckWatcherState { | 160 | CheckWatcherState { |
161 | check_enabled, | ||
152 | check_command, | 162 | check_command, |
153 | check_args, | 163 | check_args, |
154 | workspace_root, | 164 | workspace_root, |
@@ -182,6 +192,7 @@ impl CheckWatcherState { | |||
182 | 192 | ||
183 | self.watcher.cancel(); | 193 | self.watcher.cancel(); |
184 | self.watcher = WatchThread::new( | 194 | self.watcher = WatchThread::new( |
195 | self.check_enabled, | ||
185 | self.check_command.as_ref(), | 196 | self.check_command.as_ref(), |
186 | &self.check_args, | 197 | &self.check_args, |
187 | &self.workspace_root, | 198 | &self.workspace_root, |
@@ -283,6 +294,7 @@ enum CheckEvent { | |||
283 | 294 | ||
284 | impl WatchThread { | 295 | impl WatchThread { |
285 | fn new( | 296 | fn new( |
297 | check_enabled: bool, | ||
286 | check_command: Option<&String>, | 298 | check_command: Option<&String>, |
287 | check_args: &[String], | 299 | check_args: &[String], |
288 | workspace_root: &PathBuf, | 300 | workspace_root: &PathBuf, |
@@ -299,6 +311,10 @@ impl WatchThread { | |||
299 | let (message_send, message_recv) = unbounded(); | 311 | let (message_send, message_recv) = unbounded(); |
300 | let (cancel_send, cancel_recv) = unbounded(); | 312 | let (cancel_send, cancel_recv) = unbounded(); |
301 | std::thread::spawn(move || { | 313 | std::thread::spawn(move || { |
314 | if !check_enabled { | ||
315 | return; | ||
316 | } | ||
317 | |||
302 | let mut command = Command::new("cargo") | 318 | let mut command = Command::new("cargo") |
303 | .args(&args) | 319 | .args(&args) |
304 | .stdout(Stdio::piped()) | 320 | .stdout(Stdio::piped()) |