Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/lotus-state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,13 +661,13 @@ namespace fcitx {
bool wasAutoCapitalized = (currentSym != keyEvent.rawKey().sym());
if (!addedPart.empty()) {
oldPreBuffer_ = preeditStr;
if (wa_chromium_flag || wasAutoCapitalized || addedPart != keyUtf8) {
if (wa_chromium_flag) {
ic_->commitString(addedPart);
} else if (wasAutoCapitalized || addedPart != keyUtf8) {
ic_->commitString(addedPart);
LOTUS_INFO("Commit: " + addedPart);
if (!wa_chromium_flag) {
keyEvent.filterAndAccept();
isCommit = true;
}
keyEvent.filterAndAccept();
isCommit = true;
}
Comment on lines +664 to 671
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While this change corrects the logic, it introduces code duplication with ic_->commitString(addedPart) being called in both branches. You can refactor this to avoid duplication and simplify the structure, which improves maintainability.

Suggested change
if (wa_chromium_flag) {
ic_->commitString(addedPart);
} else if (wasAutoCapitalized || addedPart != keyUtf8) {
ic_->commitString(addedPart);
LOTUS_INFO("Commit: " + addedPart);
if (!wa_chromium_flag) {
keyEvent.filterAndAccept();
isCommit = true;
}
keyEvent.filterAndAccept();
isCommit = true;
}
if (wa_chromium_flag || wasAutoCapitalized || addedPart != keyUtf8) {
ic_->commitString(addedPart);
if (!wa_chromium_flag) {
LOTUS_INFO("Commit: " + addedPart);
keyEvent.filterAndAccept();
isCommit = true;
}
}

}
if (!wa_chromium_flag && !isCommit) {
Expand Down
Loading