Skip to content

Commit

Permalink
Always update ClientPreedit
Browse files Browse the repository at this point in the history
The submode update hack actually doesn't clear client preedit on key
release. If we don't reset it to empty, it may be kept.

Fix fcitx#82 fcitx#83
Closes fcitx#100
  • Loading branch information
wengxt authored and mokapsing committed Apr 30, 2024
1 parent bfe405a commit 5af8781
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/rimeengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,8 @@ RimeState *RimeEngine::state(InputContext *ic) {
return ic->propertyFor(&factory_);
}

std::string RimeEngine::subMode(const InputMethodEntry & /*entry*/, InputContext &ic) {
std::string RimeEngine::subMode(const InputMethodEntry & /*entry*/,
InputContext &ic) {
if (auto *rimeState = state(&ic)) {
return rimeState->subMode();
}
Expand Down
7 changes: 5 additions & 2 deletions src/rimestate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,12 @@ void RimeState::updatePreedit(InputContext *ic, const RimeContext &context) {
case PreeditMode::No:
ic->inputPanel().setPreedit(preeditFromRimeContext(
context, TextFormatFlag::NoFlag, TextFormatFlag::NoFlag));
ic->inputPanel().setClientPreedit(Text());
break;
case PreeditMode::CommitPreview: {
ic->inputPanel().setPreedit(preeditFromRimeContext(
context, TextFormatFlag::NoFlag, TextFormatFlag::NoFlag));
if (context.commit_text_preview) {
if (context.composition.length > 0 && context.commit_text_preview) {
Text clientPreedit;
clientPreedit.append(context.commit_text_preview,
TextFormatFlag::Underline);
Expand All @@ -300,6 +301,8 @@ void RimeState::updatePreedit(InputContext *ic, const RimeContext &context) {
clientPreedit.setCursor(clientPreedit.textLength());
}
ic->inputPanel().setClientPreedit(clientPreedit);
} else {
ic->inputPanel().setClientPreedit(Text());
}
} break;
case PreeditMode::ComposingText: {
Expand Down Expand Up @@ -381,7 +384,7 @@ void RimeState::commitPreedit(InputContext *ic) {
if (!api->get_context(session, &context)) {
return;
}
if (context.commit_text_preview) {
if (context.composition.length > 0 && context.commit_text_preview) {
ic->commitString(context.commit_text_preview);
}
api->free_context(&context);
Expand Down

0 comments on commit 5af8781

Please sign in to comment.