Skip to content

Conversation

@notfoundzzz
Copy link
Contributor

@notfoundzzz notfoundzzz commented Jan 30, 2026

如何测试

在 mogan 中插入“数学-单行公式”,然后按 I I Tab 触发 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 的几何关系计算位置,兜底保留原有计算逻辑。

@notfoundzzz notfoundzzz force-pushed the fix/math-tabcycle-popup2 branch from 64065b8 to 5d9a76b Compare January 30, 2026 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant