From 4860b523069bf03a0b4462a6f4b7d73e3724ceed Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Fri, 14 Oct 2022 15:39:55 +0800 Subject: [PATCH] InputHandler // Simplifying inline rotation method. --- Source/Modules/InputHandler_States.swift | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/Source/Modules/InputHandler_States.swift b/Source/Modules/InputHandler_States.swift index 9d35caba..31fb5e27 100644 --- a/Source/Modules/InputHandler_States.swift +++ b/Source/Modules/InputHandler_States.swift @@ -708,28 +708,15 @@ extension InputHandler { } } else { for candidate in candidates { - if candidate == currentPaired { - if reverseOrder { - if currentIndex == 0 { - currentIndex = candidates.count - 1 - } else { - currentIndex -= 1 - } - } else { - currentIndex += 1 - } - break - } - currentIndex += 1 + currentIndex = + (candidate == currentPaired && reverseOrder) + ? ((currentIndex == 0) ? candidates.count - 1 : currentIndex - 1) : currentIndex + 1 + if candidate == currentPaired { break } } } - if currentIndex >= candidates.count { - currentIndex = 0 - } - + if currentIndex >= candidates.count { currentIndex = 0 } consolidateNode(candidate: candidates[currentIndex], respectCursorPushing: false, preConsolidate: false) - delegate.switchState(generateStateOfInputting()) return true }