Pull enabled check up

This commit is contained in:
Aleksey Kladov 2020-04-01 11:01:37 +02:00
parent fae6cecf54
commit dda942debe
3 changed files with 12 additions and 11 deletions

View file

@ -24,7 +24,6 @@ pub use crate::conv::url_from_path_with_drive_lowercasing;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct CheckConfig { pub struct CheckConfig {
pub enable: bool,
pub args: Vec<String>, pub args: Vec<String>,
pub command: String, pub command: String,
pub all_targets: bool, pub all_targets: bool,
@ -216,9 +215,6 @@ impl CheckWatcherThread {
// First, clear and cancel the old thread // First, clear and cancel the old thread
self.message_recv = never(); self.message_recv = never();
self.check_process = None; self.check_process = None;
if !self.options.enable {
return;
}
let mut args: Vec<String> = vec![ let mut args: Vec<String> = vec![
self.options.command.clone(), self.options.command.clone(),

View file

@ -101,11 +101,14 @@ fn get_config(
chaining_hints: config.inlay_hints_chaining, chaining_hints: config.inlay_hints_chaining,
max_length: config.inlay_hints_max_length, max_length: config.inlay_hints_max_length,
}, },
check: CheckConfig { check: if config.cargo_watch_enable {
enable: config.cargo_watch_enable, Some(CheckConfig {
args: config.cargo_watch_args.clone(), args: config.cargo_watch_args.clone(),
command: config.cargo_watch_command.clone(), command: config.cargo_watch_command.clone(),
all_targets: config.cargo_watch_all_targets, all_targets: config.cargo_watch_all_targets,
})
} else {
None
}, },
rustfmt_args: config.rustfmt_args.clone(), rustfmt_args: config.rustfmt_args.clone(),
vscode_lldb: config.vscode_lldb, vscode_lldb: config.vscode_lldb,

View file

@ -32,6 +32,8 @@ use ra_db::ExternSourceId;
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
fn create_watcher(workspaces: &[ProjectWorkspace], config: &Config) -> Option<CheckWatcher> { fn create_watcher(workspaces: &[ProjectWorkspace], config: &Config) -> Option<CheckWatcher> {
let check_config = config.check.as_ref()?;
// FIXME: Figure out the multi-workspace situation // FIXME: Figure out the multi-workspace situation
workspaces workspaces
.iter() .iter()
@ -41,7 +43,7 @@ fn create_watcher(workspaces: &[ProjectWorkspace], config: &Config) -> Option<Ch
}) })
.map(|cargo| { .map(|cargo| {
let cargo_project_root = cargo.workspace_root().to_path_buf(); let cargo_project_root = cargo.workspace_root().to_path_buf();
Some(CheckWatcher::new(config.check.clone(), cargo_project_root)) Some(CheckWatcher::new(check_config.clone(), cargo_project_root))
}) })
.unwrap_or_else(|| { .unwrap_or_else(|| {
log::warn!("Cargo check watching only supported for cargo workspaces, disabling"); log::warn!("Cargo check watching only supported for cargo workspaces, disabling");
@ -56,7 +58,7 @@ pub struct Config {
pub line_folding_only: bool, pub line_folding_only: bool,
pub inlay_hints: InlayHintsConfig, pub inlay_hints: InlayHintsConfig,
pub rustfmt_args: Vec<String>, pub rustfmt_args: Vec<String>,
pub check: CheckConfig, pub check: Option<CheckConfig>,
pub vscode_lldb: bool, pub vscode_lldb: bool,
pub proc_macro_srv: Option<String>, pub proc_macro_srv: Option<String>,
} }