Skip to content

Commit

Permalink
Improve %% escaping error message (#13018)
Browse files Browse the repository at this point in the history
  • Loading branch information
abrassel authored Mar 4, 2025
1 parent 9440fea commit 82f8ac2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion helix-core/src/command_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ impl fmt::Display for ParseArgsError<'_> {
write!(f, "flag '--{flag}' missing an argument")
}
Self::MissingExpansionDelimiter { expansion } => {
write!(f, "missing a string delimiter after '%{expansion}'")
if expansion.is_empty() {
write!(f, "'%' was not properly escaped. Please use '%%'")
} else {
write!(f, "missing a string delimiter after '%{expansion}'")
}
}
Self::UnknownExpansion { kind } => {
write!(f, "unknown expansion '{kind}'")
Expand Down
11 changes: 11 additions & 0 deletions helix-term/tests/test/command_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,14 @@ async fn shell_expansion() -> anyhow::Result<()> {

Ok(())
}

#[tokio::test(flavor = "multi_thread")]
async fn percent_escaping() -> anyhow::Result<()> {
test_statusline(
r#":sh echo hello 10%"#,
"'run-shell-command': '%' was not properly escaped. Please use '%%'",
Severity::Error,
)
.await?;
Ok(())
}

0 comments on commit 82f8ac2

Please sign in to comment.