about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2025-07-28 11:28:24 +0100
committerWilfred Hughes <me@wilfred.me.uk>2025-07-28 11:33:46 +0100
commitd51db69e09e00b2283c18f0cdf5415992a396592 (patch)
tree10754f152978b4139be35a931245079d1dbc2000
parentd976ef8ae494cc8fd6672d43c49377e43c2876b5 (diff)
downloadrust-d51db69e09e00b2283c18f0cdf5415992a396592.tar.gz
rust-d51db69e09e00b2283c18f0cdf5415992a396592.zip
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.
-rw-r--r--src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs
index bec57a4bede..512ce0b9de3 100644
--- a/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs
+++ b/src/tools/rust-analyzer/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::<Vec<_>>();
+
+                write!(f, "{command} {}", display_args.join(" "))
             }
         }
     }