fix: Caps Lock 中英切换不再吞掉已输入拼音 - #11
Open
chriscco wants to merge 1 commit into
Open
Conversation
ascii_composer.switch_key 的 Caps_Lock 由 clear 改为 commit_code。 librime 中 clear 对应 ctx->Clear(),会直接丢弃尚未上屏的拼音组合; commit_code 对应 ctx->ClearNonConfirmedComposition(); ctx->Commit(), 会把已输入的拼音原样提交为文本。之前配置为 clear 导致中文输入到一半 按 Caps 切换英文时,已经打出的字符直接消失,而不是像 macOS 原生输入法 那样原样落到输入框里。改为 commit_code 后行为与原生一致。
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.
需求 / 问题
用中文输入法打字时,经常出现忘记切换到英文输入法、已经打了几个拼音字母才发现的情况。这时按 Caps Lock 想切到英文,期望的行为是像 macOS 原生中文输入法那样:已经打出的字符原样落到输入框里,不会消失,然后继续用英文输入。
但 TriFecta 目前的行为是:按下 Caps Lock 后,还没上屏的拼音直接被吞掉、凭空消失,需要重新输入,体验上不如原生输入法顺手。
根因
data/plum/default.yaml中ascii_composer.switch_key.Caps_Lock配置为clear。查看 librime 源码
src/rime/gear/ascii_composer.cc中SwitchAsciiMode()的实现:clear→ctx->Clear():直接丢弃尚未上屏的组合,这就是已输入拼音消失的原因。commit_code→ctx->Commit():把已输入的拼音原样提交为文本,与 macOS 原生输入法切换时的表现一致。修改
data/plum/default.yaml:单行配置改动,不涉及代码逻辑,行为已对照 librime 源码确认。