mirror of
https://github.com/mii443/AzooKeyKanaKanjiConverter.git
synced 2025-12-03 02:58:27 +00:00
fix: xn→ん の変換が n+子音→ん+子音 の挙動で上書きされてしまう問題を修正
This commit is contained in:
@@ -227,7 +227,8 @@ public struct ComposingText: Sendable {
|
||||
return
|
||||
}
|
||||
let n_prefix = self.input[0 ..< inputCursorPosition].suffix {$0.character == "n" && $0.inputStyle == .roman2kana}
|
||||
if n_prefix.count % 2 == 1 && !["n", "a", "i", "u", "e", "o", "y"].contains(first) {
|
||||
if n_prefix.count % 2 == 1 && !["n", "a", "i", "u", "e", "o", "y"].contains(first)
|
||||
&& self.input.dropLast(n_prefix.count).last != .init(character: "x", inputStyle: .roman2kana) {
|
||||
self.input[inputCursorPosition - 1] = InputElement(character: "ん", inputStyle: .direct)
|
||||
self.input.insert(contentsOf: string.map {InputElement(character: $0, inputStyle: inputStyle)}, at: inputCursorPosition)
|
||||
return
|
||||
@@ -428,12 +429,18 @@ extension ComposingText {
|
||||
return true
|
||||
}
|
||||
let n_suffix = originalElements[0 ..< leftIndex].suffix(while: {$0.inputStyle == .roman2kana && $0.character == "n"})
|
||||
// 末尾のnが偶数個で右側にnがなければvalid
|
||||
if n_suffix.count % 2 == 0 && !n_suffix.isEmpty {
|
||||
return true
|
||||
}
|
||||
// 末尾のnが奇数個で、なお直後の文字が母音・ny-・nnではない場合はvalid
|
||||
if n_suffix.count % 2 == 1 && !["a", "i", "u", "e", "o", "y", "n"].contains(firstElement.character) {
|
||||
return true
|
||||
}
|
||||
// 末尾のnが奇数個で、なおかつその1つ前の文字がxであればvalid (xn→ん、への対応)
|
||||
if n_suffix.count % 2 == 1 && originalElements.dropLast(n_suffix.count).last == .init(character: "x", inputStyle: .roman2kana) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user