Skip to content

Commit

Permalink
Fix choseong converted into jongseong even TreatJongseongAsChoseong
Browse files Browse the repository at this point in the history
… is off (#530)

* Add failed test for #529

* Fix #529

Choseong converted into jongseong even `TreatJongseongAsChoseong` is off

* Update CHANGELOG
  • Loading branch information
Riey committed Oct 3, 2021
1 parent a1d357a commit 23ba64a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 18 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
39 changes: 27 additions & 12 deletions src/engine/backends/hangul/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
14 changes: 13 additions & 1 deletion src/engine/core/tests/sebeolsik_3_90.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -24,7 +36,7 @@ fn compose_choseong_ssang() {
(Key::normal(X), "각", ""),
(Key::normal(K), "ㄱ", "각"),
(Key::normal(D), "기", ""),
])
]);
}

#[test]
Expand Down
6 changes: 1 addition & 5 deletions src/engine/core/tests/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 23ba64a

Please sign in to comment.