Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

fix(core): don't insert a space between ¥ and the amount (#4450)

Younes Berianeebd0d4be54de
diff --git a/harper-core/src/currency.rs b/harper-core/src/currency.rs
index e123c632d..690bb0f17 100644
--- a/harper-core/src/currency.rs
+++ b/harper-core/src/currency.rs
@@ -79,7 +79,7 @@ impl Currency {
Currency::Ruble => format!("{amount} {c}"),
Currency::Lira => format!("{amount} {c}"),
Currency::Pound => format!("{c}{amount}"),
- Currency::Yen => format!("{c} {amount}"),
+ Currency::Yen => format!("{c}{amount}"),
Currency::Baht => format!("{amount} {c}"),
Currency::Won => format!("{c} {amount}"),
Currency::Kip => format!("{c}{amount}"),
diff --git a/harper-core/src/linting/currency_placement.rs b/harper-core/src/linting/currency_placement.rs
index 896fec3b9..78b0391c2 100644
--- a/harper-core/src/linting/currency_placement.rs
+++ b/harper-core/src/linting/currency_placement.rs
@@ -136,6 +136,38 @@ mod tests {
);
}
+ #[test]
+ fn yen_allows_correct() {
+ assert_lint_count("It cost ¥380.", CurrencyPlacement::default(), 0);
+ }
+
+ #[test]
+ fn multiple_yen() {
+ assert_suggestion_result(
+ "They were either 380¥ 24¥ or 23¥.",
+ CurrencyPlacement::default(),
+ "They were either ¥380 ¥24 or ¥23.",
+ );
+ }
+
+ #[test]
+ fn yen_with_space() {
+ assert_suggestion_result(
+ "It cost ¥ 380.",
+ CurrencyPlacement::default(),
+ "It cost ¥380.",
+ );
+ }
+
+ #[test]
+ fn yen_after_with_space() {
+ assert_suggestion_result(
+ "It cost 380 ¥.",
+ CurrencyPlacement::default(),
+ "It cost ¥380.",
+ );
+ }
+
#[test]
fn suffix() {
assert_suggestion_result(