-
Notifications
You must be signed in to change notification settings - Fork 95
Fix visual selection range handling for :'<,'>ClaudeCodeSend #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
0c2a914 to
19315c4
Compare
Adds range-selection handling via marks, fixes visual selection fallback, and guards terminal.setup call for tests. Resolves #25. Co-authored-by: Thomas Kosiewski <[email protected]>
19315c4 to
f793344
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Enhance ClaudeCodeSend to correctly handle range selections from :'<,'>, improve test stability, and guard terminal setup in test environments.
- Added
get_range_selectionfor extracting text by marks and extendedsend_at_mention_for_visual_selectionto accept optional range arguments. - Updated command registration in
init.luato forwardline1/line2, exit visual mode, and focus the terminal only when available. - Expanded unit tests to cover valid/invalid range cases and prevent test crashes by conditioning
terminal_module.setup.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/claudecode_send_command_spec.lua | Added range-related tests and a guarded restore of the original require. |
| tests/selection_test.lua | Introduced comprehensive get_range_selection and range-send tests. |
| lua/claudecode/visual_commands.lua | Added safe fallback to vim.fn.mode for mode checks in test environments. |
| lua/claudecode/selection.lua | Implemented get_range_selection and range-aware send_at_mention_for_visual_selection. |
| lua/claudecode/init.lua | Forwarded range parameters in command callback and guarded terminal.setup. |
|
|
||
| after_each(function() | ||
| -- Restore original require | ||
| _G.require = require |
Copilot
AI
Jun 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The after_each hook restores require to the already-overridden global instead of the original. Change _G.require = require to _G.require = original_require so the original loader is properly restored.
| _G.require = require | |
| _G.require = original_require |
lua/claudecode/visual_commands.lua
Outdated
| -- Use pcall to handle test environments | ||
| local mode_success = pcall(function() | ||
| current_mode = vim.api.nvim_get_mode().mode | ||
| if vim.api and vim.api.nvim_get_mode then |
Copilot
AI
Jun 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The mode‐detection logic (vim.api.nvim_get_mode vs vim.fn.mode) is duplicated across functions. Consider extracting it into a shared helper to reduce repetition and make future updates easier.
…tection helper - Fix require restoration in test file to use original_require variable - Extract mode detection logic to shared helper function to reduce duplication - All quality gates pass: nix fmt, make check, make test Co-authored-by: ThomasK33 <[email protected]>
This release includes significant feature additions and bug fixes: **Version Updates:** - Updated main version table in lua/claudecode/init.lua (0.1.0-alpha → 0.2.0) - Updated client versions in scripts/claude_interactive.sh (3 locations) - Updated ClaudeCodeNvim version in scripts/lib_claude.sh - Removed prerelease flag for stable release **Documentation:** - Added comprehensive CHANGELOG.md with v0.2.0 release notes - Documented all merged PRs since v0.1.0 with proper references - Updated CLAUDE.md with detailed release process documentation - Fixed diff keymap references in README.md (<leader>da → <leader>aa) **Features Added (since v0.1.0):** - Diagnostics integration (#34) - File explorer support for oil.nvim, nvim-tree, neotree (#27, #22) - Enhanced terminal management with ClaudeCodeFocus command (#40) - Auto terminal provider detection (#36) - Customizable diff keymaps via LazyVim spec (#47) **Bug Fixes:** - Terminal focus errors when buffer hidden (#43) - Improved diff acceptance behavior (#41) - Fixed syntax highlighting in proposed diff view (#32) - Visual selection range handling improvements (#26) - Native terminal bufhidden behavior (#39) All code quality checks pass and documentation is updated for maintainability. Change-Id: I0e4e7c9bae98df922356dc8b8aa0acd7e8293a48 Signed-off-by: Thomas Kosiewski <[email protected]>
This release includes significant feature additions and bug fixes: **Version Updates:** - Updated main version table in lua/claudecode/init.lua (0.1.0-alpha → 0.2.0) - Updated client versions in scripts/claude_interactive.sh (3 locations) - Updated ClaudeCodeNvim version in scripts/lib_claude.sh - Removed prerelease flag for stable release **Documentation:** - Added comprehensive CHANGELOG.md with v0.2.0 release notes - Documented all merged PRs since v0.1.0 with proper references - Updated CLAUDE.md with detailed release process documentation - Fixed diff keymap references in README.md (<leader>da → <leader>aa) **Features Added (since v0.1.0):** - Diagnostics integration (#34) - File explorer support for oil.nvim, nvim-tree, neotree (#27, #22) - Enhanced terminal management with ClaudeCodeFocus command (#40) - Auto terminal provider detection (#36) - Customizable diff keymaps via LazyVim spec (#47) **Bug Fixes:** - Terminal focus errors when buffer hidden (#43) - Improved diff acceptance behavior (#41) - Fixed syntax highlighting in proposed diff view (#32) - Visual selection range handling improvements (#26) - Native terminal bufhidden behavior (#39) All code quality checks pass and documentation is updated for maintainability. Change-Id: I0e4e7c9bae98df922356dc8b8aa0acd7e8293a48 Signed-off-by: Thomas Kosiewski <[email protected]>
Summary
This change adds robust range-selection support to
ClaudeCodeSendand fixes a related test instability.•
:'<,'>ClaudeCodeSendnow works reliably after leaving visual mode by reading the'<and'>marks.• Existing visual/tracked-selection behaviour remains unchanged.
• Unit tests now cover range scenarios.
•
terminal_module.setupis called only when the stub exposes it, preventing unit-test crashes.Implementation highlights
selection.lua
• Added
get_range_selection(line1, line2)helper to extract text via marks.•
send_at_mention_for_visual_selectionaccepts optionalline1/line2.init.lua
•
ClaudeCodeSenddetects command-range usage and forwardsline1,line2.• Guarded
terminal_module.setupcall with a type check.tests/
• New
tests/unit/claudecode_send_command_spec.luaverifies command registration, parameter passing, and edge cases.Issue fixed
Fixes #25 –
:'<,'>ClaudeCodeSendpreviously reported “No visual selection”.