[222_36] 修复数学补全Tab cycling 弹窗位置参考错误 #2722
Open
+21
−6
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.
如何测试
在 mogan 中插入“数学-单行公式”,然后按
IITab触发 tab cycling。弹窗应出现在光标附近,而不会被推到很右侧。2026/01/30
Why
Tab cycling 复杂符号时,数学补全弹窗获取光标位置的时序不一致,可能在光标坐标更新前就显示,导致弹窗停留在上一候选的位置。
What
增加一次事件循环的延迟重定位,等光标位置更新后再移动弹窗,避免因时序不同而偏移。
How
QTMMathCompletionPopup::showMathCompletions内新增QTimer::singleShot(0, ...),在下一轮事件循环重新计算弹窗坐标并移动。2026/01/28
Why
数学补全弹窗的位置基于缓存的光标坐标计算,在遇到
math-big-operator包裹的大符号时,字形 extents 异常放大,导致cached_cursor_x极大,弹窗被推到很右侧。What
改为优先使用
QTMWidget里的真实光标像素坐标进行定位,并在不可用时回退旧的缓存坐标计算,避免被大符号字形影响。How
QTMWidget暴露只读的cursorPos()供弹窗取用。QTMMathCompletionPopup::getCachedPosition首选cursorPos + origin + surface的几何关系计算位置,兜底保留原有计算逻辑。