correct logic wa_chromium_flag#195
Closed
Zebra2711 wants to merge 1 commit intoLotusInputMethod:devfrom
Closed
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the string commitment logic in src/lotus-state.cpp to handle the wa_chromium_flag independently, ensuring that logging and event filtering are bypassed when the flag is active. A review comment suggests a more concise implementation to avoid duplicating the commitString call.
Comment on lines
+664
to
671
| 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; | ||
| } |
Contributor
There was a problem hiding this comment.
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; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
:)))))) làm gọn cái hàm if else xong bị sai logic