Skip to content
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

記号をかな入力に割り当てているときシフト入力と判定してしまうバグを修正 #228

Merged
merged 1 commit into from
Oct 21, 2024
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
2 changes: 1 addition & 1 deletion macSKK/StateMachine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ final class StateMachine {
}
let result = Global.kanaRule.convert(characters)
if let moji = result.kakutei {
if moji.kana.isHiragana {
if action.shiftIsPressed() && moji.kana.isHiragana {
state.inputMethod = .composing(
ComposingState(isShift: true, text: moji.kana.map { String($0) }, romaji: result.input))
updateMarkedText()
Expand Down
7 changes: 5 additions & 2 deletions macSKKTests/StateMachineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,18 @@ final class StateMachineTests: XCTestCase {
let stateMachine = StateMachine(initialState: IMEState(inputMode: .direct))
Global.kanaRule = try! Romaji(source: [";,っ", ":,<shift>;"].joined(separator: "\n"))
let expectation = XCTestExpectation()
stateMachine.inputMethodEvent.collect(3).sink { events in
stateMachine.inputMethodEvent.collect(4).sink { events in
XCTAssertEqual(events[0], .fixedText(":"))
XCTAssertEqual(events[1], .modeChanged(.hiragana, .zero))
XCTAssertEqual(events[2], .markedText(MarkedText([.markerCompose, .plain("っ")])))
XCTAssertEqual(events[2], .fixedText("っ"))
XCTAssertEqual(events[3], .markedText(MarkedText([.markerCompose, .plain("っ")])))
expectation.fulfill()
}.store(in: &cancellables)
// direct時はローマ字かな変換テーブルは関係なく ":" が入力される
XCTAssertTrue(stateMachine.handle(printableKeyEventAction(character: ":", characterIgnoringModifier: ";", withShift: true)))
XCTAssertTrue(stateMachine.handle(hiraganaAction))
// 非StickyShiftでシフトなしで ";" 入力時は "っ" が入力される
XCTAssertTrue(stateMachine.handle(Action(keyBind: nil, event: generateNSEvent(character: ";", characterIgnoringModifiers: ";"), cursorPosition: .zero)))
// ひらがなモード時はローマ字かな変換テーブルが参照され "っ" がシフトを押しながら入力されたとする
XCTAssertTrue(stateMachine.handle(printableKeyEventAction(character: ":", characterIgnoringModifier: ";", withShift: true)))
wait(for: [expectation], timeout: 1.0)
Expand Down