From 58fc69a852d12b43b133834fadfbe2d377a9146b Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Mon, 28 Jul 2025 11:28:24 +0100 Subject: [PATCH] Don't show '$saved_file' literally in IDE status updates We've had a few users get confused when VS Code shows `my_custom_check --args $saved_file`, as it looks like substitution didn't occur. Instead, show `my_custom_check --args ...` in the display output. This is also shorter, and the VS Code status bar generally works best with short text. --- crates/rust-analyzer/src/flycheck.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/rust-analyzer/src/flycheck.rs b/crates/rust-analyzer/src/flycheck.rs index bec57a4bed..512ce0b9de 100644 --- a/crates/rust-analyzer/src/flycheck.rs +++ b/crates/rust-analyzer/src/flycheck.rs @@ -111,7 +111,18 @@ impl fmt::Display for FlycheckConfig { match self { FlycheckConfig::CargoCommand { command, .. } => write!(f, "cargo {command}"), FlycheckConfig::CustomCommand { command, args, .. } => { - write!(f, "{command} {}", args.join(" ")) + // Don't show `my_custom_check --foo $saved_file` literally to the user, as it + // looks like we've forgotten to substitute $saved_file. + // + // Instead, show `my_custom_check --foo ...`. The + // actual path is often too long to be worth showing + // in the IDE (e.g. in the VS Code status bar). + let display_args = args + .iter() + .map(|arg| if arg == SAVED_FILE_PLACEHOLDER { "..." } else { arg }) + .collect::>(); + + write!(f, "{command} {}", display_args.join(" ")) } } }