Skip to content

feat: 实现getSelectedContent获取选中内容功能#9

Merged
lzx8589561 merged 2 commits into
ZToolsCenter:mainfrom
Particaly:feature/get-selected-content
Jun 3, 2026
Merged

feat: 实现getSelectedContent获取选中内容功能#9
lzx8589561 merged 2 commits into
ZToolsCenter:mainfrom
Particaly:feature/get-selected-content

Conversation

@Particaly

Copy link
Copy Markdown
Contributor

mac还需要测试编译有没有问题,我这边没有测试环境
支持获取文本、文件、图像三种类型

  • Windows: 优先使用UI Automation API,回退到剪贴板方法
  • macOS: 使用模拟复制方法(Cmd+C)
  • 添加剪贴板监控暂停/恢复功能,防止误触发
  • 自动保存和恢复原剪贴板内容
  • 支持Cursor、VS Code等Electron应用
  • 添加测试文件test-selected-content.js

支持获取文本、文件、图像三种类型
- Windows: 优先使用UI Automation API,回退到剪贴板方法
- macOS: 使用模拟复制方法(Cmd+C)
- 添加剪贴板监控暂停/恢复功能,防止误触发
- 自动保存和恢复原剪贴板内容
- 支持Cursor、VS Code等Electron应用
- 添加测试文件test-selected-content.js

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/binding_mac.cpp
Comment thread src/binding_windows.cpp Outdated
Comment thread src/binding_windows.cpp Outdated
Comment thread src/binding_windows.cpp Outdated
Comment thread src/binding_windows.cpp Outdated
Comment thread src/binding_windows.cpp
Comment thread src/binding_windows.cpp
@lzx8589561 lzx8589561 merged commit 629e4e4 into ZToolsCenter:main Jun 3, 2026
3 checks passed
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.

2 participants