Skip to content

Commit b0b2ee1

Browse files
tianjianjiangclaude
andcommitted
fix(keyhandler): skip observe in PlainBopomofo, fix leftValue sentinel
- Guard observe() and saveContextualUserModel with _inputMode != InputModePlainBopomofo check. PlainBopomofo mode is for phonetic display only and should not train the user model. - Set leftValue to kStartSentinel (not empty string) at sentence start, matching the leftReading sentinel for consistency. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2475b69 commit b0b2ee1

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

Source/KeyHandler.mm

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,19 @@ - (void)fixNodeWithReading:(NSString *)reading value:(NSString *)value originalC
207207
return;
208208
}
209209

210-
std::string leftReading = Formosa::Gramambular2::ContextualUserModel::kStartSentinel;
211-
std::string leftValue;
212-
if (nodeIter != _latestWalk.nodes.cbegin()) {
213-
auto prevNode = *(nodeIter - 1);
214-
leftReading = prevNode->reading();
215-
leftValue = prevNode->value();
216-
}
217-
_contextualUserModel->observe(leftReading, leftValue,
218-
currentNode->reading(), currentNode->value(),
219-
[NSDate date].timeIntervalSince1970);
220-
[LanguageModelManager saveContextualUserModel];
210+
if (_inputMode != InputModePlainBopomofo) {
211+
std::string leftReading = Formosa::Gramambular2::ContextualUserModel::kStartSentinel;
212+
std::string leftValue = Formosa::Gramambular2::ContextualUserModel::kStartSentinel;
213+
if (nodeIter != _latestWalk.nodes.cbegin()) {
214+
auto prevNode = *(nodeIter - 1);
215+
leftReading = prevNode->reading();
216+
leftValue = prevNode->value();
217+
}
218+
_contextualUserModel->observe(leftReading, leftValue,
219+
currentNode->reading(), currentNode->value(),
220+
[NSDate date].timeIntervalSince1970);
221+
[LanguageModelManager saveContextualUserModel];
222+
}
221223

222224
if (flag && Preferences.moveCursorAfterSelectingCandidate) {
223225
_grid->setCursor(accumulatedCursor);

0 commit comments

Comments
 (0)