diff --git a/Source/Modules/ControllerModules/KeyHandler.h b/Source/Modules/ControllerModules/KeyHandler.h index dd45b041..020bad09 100644 --- a/Source/Modules/ControllerModules/KeyHandler.h +++ b/Source/Modules/ControllerModules/KeyHandler.h @@ -74,6 +74,7 @@ struct BufferStatePackage - (BOOL)isPrintable:(UniChar)charCode; - (NSArray *)buildAssociatePhraseArrayWithKey:(NSString *)key; - (NSArray *)getCandidatesArray; +- (NSInteger)getKeyLengthAtIndexZero; - (NSInteger)getBuilderCursorIndex; - (NSInteger)getBuilderLength; - (NSInteger)getPackagedCursorIndex; diff --git a/Source/Modules/ControllerModules/KeyHandler.mm b/Source/Modules/ControllerModules/KeyHandler.mm index c9be6c67..97eb3053 100644 --- a/Source/Modules/ControllerModules/KeyHandler.mm +++ b/Source/Modules/ControllerModules/KeyHandler.mm @@ -623,6 +623,11 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; return candidatesArray; } +- (NSInteger)getKeyLengthAtIndexZero +{ + return [NSString stringWithUTF8String:_walkedNodes[0].node->currentKeyValue().value.c_str()].length; +} + #pragma mark - 威注音認為有必要單獨拿出來處理的部分,交給 Swift 則有些困難。 - (BOOL)isPrintable:(UniChar)charCode diff --git a/Source/Modules/ControllerModules/KeyHandler_Misc.swift b/Source/Modules/ControllerModules/KeyHandler_Misc.swift index b215d86b..0421a562 100644 --- a/Source/Modules/ControllerModules/KeyHandler_Misc.swift +++ b/Source/Modules/ControllerModules/KeyHandler_Misc.swift @@ -41,7 +41,11 @@ import Cocoa && (cursorIndex < getBuilderLength())) || cursorIndex == 0 { - cursorIndex += 1 + if cursorIndex == 0 && !mgrPrefs.setRearCursorMode { + cursorIndex += getKeyLengthAtIndexZero() + } else { + cursorIndex += 1 + } } return cursorIndex }