Skip to content

[1243] 打开 AI 侧边栏时自动填入文档选区内容 - #4437

Open
da-liii wants to merge 2 commits into
mainfrom
da/1243/llm_input
Open

[1243] 打开 AI 侧边栏时自动填入文档选区内容#4437
da-liii wants to merge 2 commits into
mainfrom
da/1243/llm_input

Conversation

@da-liii

@da-liii da-liii commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

What

文档中存在选区时,打开 AI 对话侧边栏(点击右上角按钮或 std j),若当前会话输入区为空,自动把选中内容填入输入区。

How

  • 判定逻辑全在 scheme 侧(llm 插件),复用 chat-tab-buffer-empty? / chat-tab-empty-body? / chat-tab-set-input-body!
  • C++ 只在 sync_chat_sidebar_mode() 的「隐藏→显示」转换时、focusInput() 之前调一行 call(此时 current editor 仍是文档编辑器,selection-tree 能取到选区;同时覆盖按钮与快捷键两条打开路径)
  • 输入区已有内容不覆盖;chat 相关 buffer(tmfs://chat 前缀)不作为选区来源

测试

  • xmake r 1243:15 correct, 0 failed(headless 与 GUI 模式均通过)
  • 细节见 devel/1243.md

🤖 Generated with Claude Code

da-liii and others added 2 commits August 26, 2026 15:02
Co-Authored-By: Claude <noreply@anthropic.com>
- scheme 纯判定 chat-tab-should-prefill?:输入区为空且选区非空白时预填
- scheme 包装 chat-tab-prefill-from-selection!:捕获当前编辑器选区,
  chat 相关 buffer 不作为来源
- C++ 钩子:sync_chat_sidebar_mode 隐藏→显示转换时、focusInput 之前调用

Co-Authored-By: Claude <noreply@anthropic.com>
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