Make manual flycheck runs work when checkOnSave is disabled
This commit is contained in:
parent
e0aa5afd7b
commit
cdfe98fe94
@ -1125,11 +1125,8 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn flycheck(&self) -> Option<FlycheckConfig> {
|
||||
if !self.data.checkOnSave_enable {
|
||||
return None;
|
||||
}
|
||||
let flycheck_config = match &self.data.checkOnSave_overrideCommand {
|
||||
pub fn flycheck(&self) -> FlycheckConfig {
|
||||
match &self.data.checkOnSave_overrideCommand {
|
||||
Some(args) if !args.is_empty() => {
|
||||
let mut args = args.clone();
|
||||
let command = args.remove(0);
|
||||
@ -1183,8 +1180,11 @@ impl Config {
|
||||
extra_args: self.data.checkOnSave_extraArgs.clone(),
|
||||
extra_env: self.check_on_save_extra_env(),
|
||||
},
|
||||
};
|
||||
Some(flycheck_config)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_on_save(&self) -> bool {
|
||||
self.data.checkOnSave_enable
|
||||
}
|
||||
|
||||
pub fn runnables(&self) -> RunnablesConfig {
|
||||
|
@ -581,10 +581,7 @@ impl GlobalState {
|
||||
// When we're running multiple flychecks, we have to include a disambiguator in
|
||||
// the title, or the editor complains. Note that this is a user-facing string.
|
||||
let title = if self.flycheck.len() == 1 {
|
||||
match self.config.flycheck() {
|
||||
Some(config) => format!("{}", config),
|
||||
None => "cargo check".to_string(),
|
||||
}
|
||||
format!("{}", self.config.flycheck())
|
||||
} else {
|
||||
format!("cargo check (#{})", id + 1)
|
||||
};
|
||||
@ -593,7 +590,7 @@ impl GlobalState {
|
||||
state,
|
||||
message,
|
||||
None,
|
||||
Some(format!("rust-analyzer/checkOnSave/{}", id)),
|
||||
Some(format!("rust-analyzer/flycheck/{}", id)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -796,7 +793,7 @@ impl GlobalState {
|
||||
})?
|
||||
.on::<lsp_types::notification::WorkDoneProgressCancel>(|this, params| {
|
||||
if let lsp_types::NumberOrString::String(s) = ¶ms.token {
|
||||
if let Some(id) = s.strip_prefix("rust-analyzer/checkOnSave/") {
|
||||
if let Some(id) = s.strip_prefix("rust-analyzer/flycheck/") {
|
||||
if let Ok(id) = u32::from_str_radix(id, 10) {
|
||||
if let Some(flycheck) = this.flycheck.get(id as usize) {
|
||||
flycheck.cancel();
|
||||
@ -888,14 +885,14 @@ impl GlobalState {
|
||||
}
|
||||
}
|
||||
|
||||
if run_flycheck(this, vfs_path) {
|
||||
if !this.config.check_on_save() || run_flycheck(this, vfs_path) {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
// No specific flycheck was triggered, so let's trigger all of them.
|
||||
for flycheck in this.flycheck.iter() {
|
||||
flycheck.restart();
|
||||
} else if this.config.check_on_save() {
|
||||
// No specific flycheck was triggered, so let's trigger all of them.
|
||||
for flycheck in this.flycheck.iter() {
|
||||
flycheck.restart();
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
})?
|
||||
|
@ -449,15 +449,7 @@ impl GlobalState {
|
||||
|
||||
fn reload_flycheck(&mut self) {
|
||||
let _p = profile::span("GlobalState::reload_flycheck");
|
||||
let config = match self.config.flycheck() {
|
||||
Some(it) => it,
|
||||
None => {
|
||||
self.flycheck = Arc::new([]);
|
||||
self.diagnostics.clear_check_all();
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let config = self.config.flycheck();
|
||||
let sender = self.flycheck_sender.clone();
|
||||
let invocation_strategy = match config {
|
||||
FlycheckConfig::CargoCommand { .. } => flycheck::InvocationStrategy::PerWorkspace,
|
||||
|
Loading…
x
Reference in New Issue
Block a user