[222_100] add inline spell checker#3103
Conversation
Greptile Summary此 PR 为 Mogan 编辑器实现了内联拼写检查功能,通过在光标附近的拼写错误单词下方绘制红色波浪线提示,并在点击错误单词时复用现有拼写工具栏。核心实现分为两层:C++ 侧新增 整体实现架构合理,位置观察者( Confidence Score: 4/5功能实现整体可合并,但先前评审指出的 P1 级 alternate 选区冲突问题尚未修复,建议在合并前处理。 C++ 层的位置观察者管理、重绘逻辑、胶水层绑定均实现正确。但先前评审中发现的三个问题(THE_SPELL_ERRORS 与 ControlMask 值碰撞、缓冲区切换死代码、普通拼写工具栏活跃时 alternate 选区被无条件覆盖)在当前 HEAD 中仍然存在,其中最后一项为 P1 级别,会导致用户在普通拼写检查过程中点击错误单词时丢失当前检查焦点。 TeXmacs/progs/generic/spell-widgets.scm(inline-spell-toolbar-open 中 set-alt-selection alternate 的无条件调用)及 src/Edit/editor.hpp(THE_SPELL_ERRORS 值定义) Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Scheme as spell-widgets.scm
participant Glue as Glue Layer
participant Cpp as edit_select_rep (C++)
participant Repaint as edit_interface_rep
User->>Scheme: 按键 / 鼠标点击
Scheme->>Scheme: schedule-inline-spell-underlines<br/>(串行号防抖, idle 350ms/900ms)
Scheme->>Scheme: inline-spell-current-word()<br/>tree-spell-at → sels
alt sels 非空
Scheme->>Glue: (set-spell-errors sels)
Glue->>Cpp: set_spell_errors(range_set)
Cpp->>Cpp: clear_spell_error_positions()
Cpp->>Cpp: position_new() × N
Cpp->>Repaint: notify_change(THE_SPELL_ERRORS)
else sels 为空
Scheme->>Glue: (clear-spell-errors)
Glue->>Cpp: clear_spell_errors()
Cpp->>Repaint: notify_change(THE_SPELL_ERRORS)
end
Repaint->>Repaint: apply_changes()<br/>失效旧 spell_error_rects
Repaint->>Cpp: get_spell_errors()
Cpp->>Repaint: resolve_spell_errors() → range_set
Repaint->>Repaint: 重建 spell_error_rects<br/>draw_spell_error_wave()
User->>Scheme: 鼠标左键释放 (release-left)
Scheme->>Scheme: inline-spell-underlines-refresh()
Scheme->>Scheme: inline-spell-show-toolbar-at-cursor()
Scheme->>Scheme: inline-spell-toolbar-open(sel)<br/>set-alt-selection "alternate"
Scheme->>Scheme: spell-focus-on(sel)<br/>显示拼写建议工具栏
Reviews (2): Last reviewed commit: "[222_100] add inline spell checking" | Re-trigger Greptile |
ded9bab to
540d164
Compare
|
The overall layering here looks reasonable, but I think there are two behavioral gaps that should be addressed. First, inline spell recomputation is currently tied mainly to Second, disabling "spell underlines" does not fully clear state across all views. clear-inline-spell-underlines only calls clear-spell-errors when there is a current-view, |
Closes Issue #3102
Summary
Testing
Inline spellcheckinPreferencesScreenshots
Edit > Preferences > Other > Inline spellcheckScreen.Recording.2026-04-04.at.12.24.31.mov