Skip to content

Commit

Permalink
fix: 修复当开启满4码唯一候选词上屏和临时英文功能冲突的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
qwertyyb committed Apr 23, 2023
1 parent 7c708b3 commit ab4393d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Fire/FireInputController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,14 @@ class FireInputController: IMKInputController {

override func handle(_ event: NSEvent!, client sender: Any!) -> Bool {
NSLog("[FireInputController] handle: \(event.debugDescription)")

// 在activateServer中有把IMKInputController绑定给CandidatesWindow
// 然而在实际运行中发现,在Safari地址栏输入部分原码后,再按shift切到英文输入模式下时,候选窗消失了,但原码没有上屏
// 排查发现,因为shift切换中英文是通过CandidatesWindow调用绑定的inputController方法实现的,而在safari地址栏时,接受键盘输入的inputController
// 和CandidatesWindow绑定的inputController并不是同一个,所以出现了此问题
// 这里猜测之所以会出现不一致,是因为在Safari地址栏输入场景下,会有多个TextInputClient而创建多个inputController, activateServer也会多次执行
// 但是activateServer的调用顺序并不能保证最后调用的就是接受输入事件的TextInputClient对应的inputController, 所以仅是在activateServer中绑定inputController是不行的,需要在此处再绑定一下
// 但是activateServer的调用顺序并不能保证最后调用的就是接受输入事件的TextInputClient对应的inputController
// 所以仅是在activateServer中绑定inputController是不行的,需要在此处再绑定一下
CandidatesWindow.shared.inputController = self

let handler = Utils.shared.processHandlers(handlers: [
Expand Down Expand Up @@ -334,12 +335,11 @@ class FireInputController: IMKInputController {
// 更新候选窗口
func refreshCandidatesWindow() {
updateCandidates(client())
if Defaults[.wubiAutoCommit] && _candidates.count == 1 && _originalString.count >= 4 {
if Defaults[.wubiAutoCommit] && _candidates.count == 1 && _originalString.count >= 4,
let candidate = _candidates.first, candidate.type != .placeholder {
// 满4码唯一候选词自动上屏
if let candidate = _candidates.first {
insertCandidate(candidate)
return
}
insertCandidate(candidate)
return
}
if !Defaults[.showCodeInWindow] && _candidates.count <= 0 {
// 不在候选框显示输入码时,如果候选词为空,则不显示候选框
Expand Down

0 comments on commit ab4393d

Please sign in to comment.