diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ce4e9d60..480b33f3 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -10,6 +10,7 @@ * Fix sebeolsik-3sin-p2 '"' character [#509](https://github.com/Riey/kime/issues/509) * Fix sebeolsik-391 "S-F" key [#521](https://github.com/Riey/kime/issues/521) * Don't compose choseong when FlexibleComposeOrder is on [#520](https://github.com/Riey/kime/issues/520) +* Fix choseong converted into jongseong even `TreatJongseongAsChoseong` is off [#529](https://github.com/Riey/kime/issues/529) ## 2.5.5 diff --git a/src/engine/backends/hangul/src/state.rs b/src/engine/backends/hangul/src/state.rs index b27fc8c2..470e3586 100644 --- a/src/engine/backends/hangul/src/state.rs +++ b/src/engine/backends/hangul/src/state.rs @@ -374,6 +374,14 @@ impl CharacterState { ..Default::default() }), } + } else if let Some(_) = self.jong { + // $ㅁ + ㅏ = ㅁㅏ + // 초성없이 중성과 종성만 있는 경우를 배제 + CharacterResult::NewCharacter(Self { + jung: Some(jung), + compose_jung, + ..Default::default() + }) } else { self.jung = Some(jung); self.compose_jung = compose_jung; @@ -391,19 +399,26 @@ impl CharacterState { None => { let new; - match jong.to_cho(addons) { - JongToCho::Direct(cho) => { - new = Self { - cho: Some(cho), - ..Default::default() - }; - } - JongToCho::Compose(..) => { - new = Self { - jong: Some(jong), - ..Default::default() - }; + if addons.contains(Addon::TreatJongseongAsChoseong) { + match jong.to_cho(addons) { + JongToCho::Direct(cho) => { + new = Self { + cho: Some(cho), + ..Default::default() + }; + } + JongToCho::Compose(..) => { + new = Self { + jong: Some(jong), + ..Default::default() + }; + } } + } else { + new = Self { + jong: Some(jong), + ..Default::default() + }; } CharacterResult::NewCharacter(new) diff --git a/src/engine/core/tests/sebeolsik_3_90.rs b/src/engine/core/tests/sebeolsik_3_90.rs index 94de7a0d..02045d01 100644 --- a/src/engine/core/tests/sebeolsik_3_90.rs +++ b/src/engine/core/tests/sebeolsik_3_90.rs @@ -15,6 +15,18 @@ fn hello() { ]); } +// issue #529 +#[test] +fn dont_convert_jongseong() { + test_input(&[ + (Key::normal(K), "ㄱ", ""), + (Key::normal(F), "가", ""), + (Key::normal(Z), "감", ""), + (Key::normal(Z), "ㅁ", "감"), + (Key::normal(F), "ㅏ", "ㅁ"), + ]); +} + // issue #263 #[test] fn compose_choseong_ssang() { @@ -24,7 +36,7 @@ fn compose_choseong_ssang() { (Key::normal(X), "각", ""), (Key::normal(K), "ㄱ", "각"), (Key::normal(D), "기", ""), - ]) + ]); } #[test] diff --git a/src/engine/core/tests/shared.rs b/src/engine/core/tests/shared.rs index 43b85576..b049962e 100644 --- a/src/engine/core/tests/shared.rs +++ b/src/engine/core/tests/shared.rs @@ -29,11 +29,7 @@ pub fn test_input_impl(engine: EngineConfig, category: InputCategory, keys: &[(K eprintln!("Ret: {:?}", ret); - if ret.contains(InputResult::HAS_PREEDIT) { - test_preedit!(preedit); - } else { - assert!(preedit.is_empty()); - } + test_preedit!(preedit); if ret.contains(InputResult::HAS_COMMIT) { if ret.contains(InputResult::CONSUMED) {