Skip to content

Commit a7c07f6

Browse files
authored
Merge pull request #20327 from Wilfred/saved_file_placeholder
Don't show '$saved_file' literally in IDE status updates
2 parents d026135 + d51db69 commit a7c07f6

File tree

1 file changed

+12
-1
lines changed
  • src/tools/rust-analyzer/crates/rust-analyzer/src

1 file changed

+12
-1
lines changed

src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,18 @@ impl fmt::Display for FlycheckConfig {
111111
match self {
112112
FlycheckConfig::CargoCommand { command, .. } => write!(f, "cargo {command}"),
113113
FlycheckConfig::CustomCommand { command, args, .. } => {
114-
write!(f, "{command} {}", args.join(" "))
114+
// Don't show `my_custom_check --foo $saved_file` literally to the user, as it
115+
// looks like we've forgotten to substitute $saved_file.
116+
//
117+
// Instead, show `my_custom_check --foo ...`. The
118+
// actual path is often too long to be worth showing
119+
// in the IDE (e.g. in the VS Code status bar).
120+
let display_args = args
121+
.iter()
122+
.map(|arg| if arg == SAVED_FILE_PLACEHOLDER { "..." } else { arg })
123+
.collect::<Vec<_>>();
124+
125+
write!(f, "{command} {}", display_args.join(" "))
115126
}
116127
}
117128
}

0 commit comments

Comments
 (0)