[0986] AI 操作栏居中、按选择方向定位、cmd/ctrl+j 接入对话 - #4566
Merged
Merged
Conversation
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
- 方向在 update_translate_popup 计算一次,经 show_translate_popup → setUpward 存入 popup 缓存,getCachedPosition 只读缓存,不再回查编辑器 活态(修选区变化后方向与锚行失配) - 坐标换算与视口裁剪提取为 QTMBasePopup::selectionEdgePixels / clampToViewport,基类与 AI 操作栏定位共用 - Qt 上 cmd/ctrl+j 由 QTMWidget C++ 拦截派发,scheme 侧的 ai-chat-shortcut / std j 改绑 / glue ai-action / editor.hpp 虚函数 四层均不可达,整链移除(ai_action 保留为纯 C++ 方法) - 任务文档同步为最终实现 Co-Authored-By: Claude Code <noreply@anthropic.com>
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.
What
AI 操作栏三处交互改进(基于已合并的第二步,选区引用进 AI 侧边栏):
Why
How
edit_interface_rep::selection_made_upward:选区按文档序规范化存储(start ≤ end),方向信息只在光标上——拖拽与 shift+方向键选择结束时光标tp停在「最后选中」的一端(mouse_drag 的 p2 与 tp 同源同参,严格相等),path_less_eq (tp, selection_get_start ())为真即从下往上选择;选区为空时自然回落到向下。update_translate_popup同一时刻确定,经show_translate_popup→qt_simple_widget→popup->setUpward存入 popup 缓存,getCachedPosition只读缓存字段、不回查编辑器活态——避免选区变化后「位置按新方向、锚行是旧的」失配。QTMAiTranslatePopup::getCachedPosition:x 为锚行水平中心减栏宽一半;纵向以方向无关的 first/backup 两候选取首选侧,放不下退另一侧,最终clampToViewport收敛。坐标换算与视口裁剪提取为基类QTMBasePopup::selectionEdgePixels/clampToViewport,基类与派生定位共用。edit_interface_rep::ai_action (action):第二步在onActionTriggered槽内的「取选区 +qt_chat_ai_send_selection+ dismiss」流程移入此方法(含「选区须在打开侧边栏前捕获」约束),QML 按钮槽改为一行转调,快捷键共用同一入口。QTMWidget::keyPressEvent里 [0247] 引入的 C++ 拦截(在 scheme 键位表之前return,scheme 绑定收不到该键)——拦截改为:有选区先走ai_action ("chat"),无选区保持原 dock 开关不变。测试
xmake b stem构建通过;xmake b qml_load_test && xmake r qml_load_test(24/24,AI 操作栏加载与 hover 用例回归);xmake b qt_chat_controller_test && xmake r qt_chat_controller_test(24/24,第二步composeAiInputBody用例未破);xmake r chat-list-test:llm 模块 boot 冒烟无错误;gf fmt --check全仓通过。手动验证(用户已完成)
任务文档见
devel/0986.md「追加修订(2026-09-15,基于 main;第二步已合并)」。🤖 Generated with Claude Code