Unnamed repository; edit this file 'description' to name the repository.
Improve %% escaping error message (#13018)
Alexander Brassel 12 months ago
parent 9440fea · commit 82f8ac2
-rw-r--r--helix-core/src/command_line.rs6
-rw-r--r--helix-term/tests/test/command_line.rs11
2 files changed, 16 insertions, 1 deletions
diff --git a/helix-core/src/command_line.rs b/helix-core/src/command_line.rs
index 4c762a71..960b247d 100644
--- a/helix-core/src/command_line.rs
+++ b/helix-core/src/command_line.rs
@@ -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}'")
diff --git a/helix-term/tests/test/command_line.rs b/helix-term/tests/test/command_line.rs
index d9a01669..0e227006 100644
--- a/helix-term/tests/test/command_line.rs
+++ b/helix-term/tests/test/command_line.rs
@@ -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(())
+}