-
Notifications
You must be signed in to change notification settings - Fork 15
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_selection
for extracting text by marks and extendedsend_at_mention_for_visual_selection
to accept optional range arguments. - Updated command registration in
init.lua
to 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 |
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 |
Copilot uses AI. Check for mistakes.
lua/claudecode/visual_commands.lua
Outdated
@@ -44,7 +44,11 @@ function M.validate_visual_mode() | |||
|
|||
-- 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 |
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.
Copilot uses AI. Check for mistakes.
…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]>
Summary
This change adds robust range-selection support to
ClaudeCodeSend
and fixes a related test instability.•
:'<,'>ClaudeCodeSend
now 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.setup
is 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_selection
accepts optionalline1
/line2
.init.lua
•
ClaudeCodeSend
detects command-range usage and forwardsline1
,line2
.• Guarded
terminal_module.setup
call with a type check.tests/
• New
tests/unit/claudecode_send_command_spec.lua
verifies command registration, parameter passing, and edge cases.Issue fixed
Fixes #25 –
:'<,'>ClaudeCodeSend
previously reported “No visual selection”.