diff --git a/Source/InputMethodController.mm b/Source/InputMethodController.mm index 5b9a8a96..318a7529 100644 --- a/Source/InputMethodController.mm +++ b/Source/InputMethodController.mm @@ -1301,6 +1301,8 @@ static double FindHighestScore(const vector &nodes, double epsilon) - (void)handleState:(InputState *)newState client:(id)client { + NSLog(@"current state: %@ new state: %@", _state, newState ); + if ([newState isKindOfClass:[InputStateDeactive class]]) { [self _handleInputStateDeactive:(InputStateDeactive *) newState previous:_state client:client]; } @@ -1368,6 +1370,9 @@ static double FindHighestScore(const vector &nodes, double epsilon) { NSString *poppedText = [state poppedText]; [self _commitText:poppedText client:client]; + + _builder->clear(); + _walkedNodes.clear(); gCurrentCandidateController.visible = NO; [self _hideTooltip]; } diff --git a/Source/InputState.swift b/Source/InputState.swift index 4a00551e..e2fcf57c 100644 --- a/Source/InputState.swift +++ b/Source/InputState.swift @@ -6,6 +6,9 @@ class InputState: NSObject { /// Represents that the input controller is deactive. class InputStateDeactive: InputState { + override var description: String { + return "" + } } /// Represents that the composing buffer is empty. @@ -20,6 +23,10 @@ class InputStateCommitting: InputState { self.init() self.poppedText = poppedText } + + override var description: String { + return "" + } } /// Represents that the composing buffer is not empty. @@ -31,6 +38,10 @@ class InputStateNotEmpty: InputState { self.composingBuffer = composingBuffer self.cursorIndex = cursorIndex } + + override var description: String { + return "" + } } /// Represents that the user is inputting text. @@ -44,13 +55,16 @@ class InputStateInputting: InputStateNotEmpty { } @objc var attributedString: NSAttributedString { - let attrs: [NSAttributedString.Key : Any] = [ - .underlineStyle: NSUnderlineStyle.single, + let attributedSting = NSAttributedString(string: composingBuffer, attributes: [ + .underlineStyle: NSUnderlineStyle.single.rawValue, .markedClauseSegment: 0 - ] - let attributedSting = NSAttributedString(string: composingBuffer, attributes: attrs) + ]) return attributedSting } + + override var description: String { + return "" + } } private let kMinMarkRangeLength = 2 @@ -95,20 +109,24 @@ class InputStateMarking: InputStateNotEmpty { @objc var attributedString: NSAttributedString { let attributedSting = NSMutableAttributedString(string: composingBuffer) attributedSting.setAttributes([ - NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single, - NSAttributedString.Key.markedClauseSegment: 0 + .underlineStyle: NSUnderlineStyle.single.rawValue, + .markedClauseSegment: 0 ], range: NSRange(location: 0, length: markedRange.location)) attributedSting.setAttributes([ - NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single, - NSAttributedString.Key.markedClauseSegment: 1 + .underlineStyle: NSUnderlineStyle.single.rawValue, + .markedClauseSegment: 1 ], range: markedRange) attributedSting.setAttributes([ - NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single, - NSAttributedString.Key.markedClauseSegment: 2 + .underlineStyle: NSUnderlineStyle.single.rawValue, + .markedClauseSegment: 2 ], range: NSRange(location: markedRange.location + markedRange.length, length: composingBuffer.count - (markedRange.location + markedRange.length) )) return attributedSting } + + override var description: String { + return "" + } } /// Represents that the user is choosing in a candidates list. @@ -123,11 +141,14 @@ class InputStateChoosingCandidate: InputStateNotEmpty { } @objc var attributedString: NSAttributedString { - let attrs: [NSAttributedString.Key : Any] = [ - .underlineStyle: NSUnderlineStyle.single, + let attributedSting = NSAttributedString(string: composingBuffer, attributes: [ + .underlineStyle: NSUnderlineStyle.single.rawValue, .markedClauseSegment: 0 - ] - let attributedSting = NSAttributedString(string: composingBuffer, attributes: attrs) + ]) return attributedSting } + + override var description: String { + return "" + } }