Skip to content

Fix choseong converted into jongseong even TreatJongseongAsChoseong is off #530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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