Repository navigation
Conversation
1. Root cause: TerminalDisplay::updateImage() only calls update() to repaint the widget after terminal content changes (line breaks, scrolling), but never calls qApp->inputMethod()->update() to notify the IME framework that the cursor rectangle has changed 2. Fix: add qApp->inputMethod()->update(Qt::ImQueryAll) with null check after update() in updateImage(), so the IME framework re-queries ImCursorRectangle and positions the candidate box correctly 3. Impact: pinyin IME candidate box now follows the cursor after line breaks and scrolling; no behavior change when no input method is active Log: fix pinyin IME candidate box not following cursor after line breaks Influence: 1. Test pinyin input after multiple line breaks in terminal 2. Test pinyin input after terminal scroll output 3. Verify no regression on mouse-click cursor positioning fix: 修复终端内容更新后输入法候选框不跟随光标位置 1. 根因:TerminalDisplay::updateImage() 在终端内容更新(换行、滚动) 后仅调用 update() 重绘控件,未调用 qApp->inputMethod()->update() 通知输入法框架光标矩形已变更 2. 方案:在 updateImage() 的 update() 之后新增带空指针保护的 qApp->inputMethod()->update(Qt::ImQueryAll) 调用,使输入法框架 重新查询 ImCursorRectangle 并正确定位候选框 3. 影响:拼音输入法候选框在换行和滚动后正确跟随光标位置;无输入法 时无行为变化 Log: 修复拼音输入法候选框在换行后不跟随光标的问题 Influence: 1. 测试终端中输入拼音后多次回车再输入拼音,验证候选框跟随光标 2. 测试终端滚动输出后输入拼音,验证候选框位置正确 3. 验证鼠标点击移动光标后输入拼音无回归 PMS: BUG-383823
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideImplementationNotify the active input method after the terminal image updates so it can re-query the cursor rectangle.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
add-uos
marked this pull request as draft
November 20, 2026 13:53
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.
Root Cause Analysis
TerminalDisplay::updateImage()is called after terminal content changes (line breaks, scrolling). The function only callsupdate()(widget repaint) at the end but never callsqApp->inputMethod()->update(Qt::ImQueryAll)to notify the IME framework that the cursor rectangle has changed. The IME framework (fcitx5) depends on this notification to re-queryImCursorRectangle; without it, the candidate box is positioned at the stale cursor location.Key evidence: defect at
3rdparty/terminalwidget/lib/TerminalDisplay.cpp:1324—updateImage()lacksinputMethod()->update()afterupdate(). Same file line 2602 (mouseReleaseEvent) already hasqApp->inputMethod()->show(), confirming this is an established pattern thatupdateImage()path missed.Fix
Add
qApp->inputMethod()->update(Qt::ImQueryAll)with null check afterupdate()inupdateImage(), so the IME framework re-queries the cursor rectangle and positions the candidate box correctly after terminal content updates.Change Safety Assessment
Code Safety
update()(line 1324) was introduced by commit24a40d79(2020), not a product of an IME-related fix; this change does not revert any historical fixupdateImage()unaffectedqApp->inputMethod()already used at line 2602 in the same fileBusiness Impact Scope
Terminal IME interaction: the pinyin IME candidate box position now follows the cursor after line breaks and scrolling. Affected callers: all paths invoking
TerminalDisplay::updateImage()(outputChanged signal, scrollbar, keyboard events) — none require modification as only an internal API call was added.Verification Suggestion
Test pinyin input after multiple line breaks in terminal; test pinyin input after terminal scroll output; verify no regression on mouse-click cursor positioning.
根因分析
TerminalDisplay::updateImage()在终端内容更新(换行、滚动)后被调用。函数末尾仅调用update()(widget 重绘),但未调用qApp->inputMethod()->update(Qt::ImQueryAll)通知输入法框架光标矩形已变更。输入法框架(fcitx5)依赖该通知触发重新查询ImCursorRectangle,缺少此调用时使用过期的光标位置定位候选框,导致候选框停留在旧位置。关键证据:缺陷位于
3rdparty/terminalwidget/lib/TerminalDisplay.cpp:1324,updateImage()的update()之后缺少inputMethod()->update()调用。同文件 line 2602(mouseReleaseEvent)已有qApp->inputMethod()->show()调用,说明输入法通知是既有模式,updateImage()路径遗漏了。修复方案
在
updateImage()的update()调用之后,新增带空指针保护的qApp->inputMethod()->update(Qt::ImQueryAll)调用,使输入法框架在终端内容更新后重新查询光标矩形,正确定位候选框。改动安全评估
代码安全评估
update()(line 1324)由 commit24a40d79(2020)引入,非输入法相关修复产物,本次改动不撤销任何历史修复updateImage()所有调用者不受影响qApp->inputMethod()模式在同文件 line 2602 已有使用业务影响范围
终端输入法交互:拼音输入法候选框在换行和滚动后正确跟随光标位置。受影响调用者:
TerminalDisplay::updateImage()的所有调用路径(outputChanged 信号、滚动条、键盘事件),均无需修改——仅内部新增 API 调用。验证建议
测试终端中输入拼音后多次回车再输入拼音,验证候选框跟随光标;测试终端滚动后输入拼音候选框位置正确;验证鼠标点击移动光标后输入拼音无回归。
PMS: BUG-383823
Summary by Sourcery
Bug Fixes: