feat: 实现getSelectedContent获取选中内容功能#9
Conversation
支持获取文本、文件、图像三种类型 - Windows: 优先使用UI Automation API,回退到剪贴板方法 - macOS: 使用模拟复制方法(Cmd+C) - 添加剪贴板监控暂停/恢复功能,防止误触发 - 自动保存和恢复原剪贴板内容 - 支持Cursor、VS Code等Electron应用 - 添加测试文件test-selected-content.js
There was a problem hiding this comment.
Code Review
This pull request introduces a new getSelectedContent API to retrieve currently selected text, files, or images on both Windows and macOS, along with pause and resume controls for the clipboard monitor to prevent self-triggering. The review feedback highlights several critical issues: the macOS implementation relies on inefficient and fragile shell command executions (popen/system) and hardcoded temporary files, which should be refactored using native Cocoa APIs. On Windows, multiple 1-byte buffer overflows were identified due to incorrect buffer size parameters in WideCharToMultiByte conversions, alongside potential memory leaks where allocated global memory is not freed on failure, and robustness issues in buffer size tracking and bitmap resource management.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
mac还需要测试编译有没有问题,我这边没有测试环境
支持获取文本、文件、图像三种类型