Skip to content

Commit 7f1ca9e

Browse files
Fix Luacheck linting issues
- Remove trailing whitespace from selection.lua and test files - Convert whitespace-only lines to empty lines - Ensures CI passes by meeting code style requirements Co-authored-by: ThomasK33 <[email protected]>
1 parent 0586c8d commit 7f1ca9e

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

lua/claudecode/selection.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,10 +585,10 @@ function M.get_range_selection(line1, line2)
585585

586586
local current_buf = vim.api.nvim_get_current_buf()
587587
local file_path = vim.api.nvim_buf_get_name(current_buf)
588-
588+
589589
-- Get the total number of lines in the buffer
590590
local total_lines = vim.api.nvim_buf_line_count(current_buf)
591-
591+
592592
-- Ensure line2 doesn't exceed buffer bounds
593593
if line2 > total_lines then
594594
line2 = total_lines

tests/selection_test.lua

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ describe("Range Selection Tests", function()
466466
name = "/test/file.lua",
467467
lines = {
468468
"line 1",
469-
"line 2",
469+
"line 2",
470470
"line 3",
471471
"line 4",
472472
"line 5",
@@ -498,7 +498,7 @@ describe("Range Selection Tests", function()
498498
describe("get_range_selection", function()
499499
it("should return valid selection for valid range", function()
500500
local result = selection.get_range_selection(2, 4)
501-
501+
502502
assert(result ~= nil)
503503
assert(result.text == "line 2\nline 3\nline 4")
504504
assert(result.filePath == "/test/file.lua")
@@ -512,7 +512,7 @@ describe("Range Selection Tests", function()
512512

513513
it("should return valid selection for single line range", function()
514514
local result = selection.get_range_selection(3, 3)
515-
515+
516516
assert(result ~= nil)
517517
assert(result.text == "line 3")
518518
assert(result.selection.start.line == 2) -- 0-indexed
@@ -522,7 +522,7 @@ describe("Range Selection Tests", function()
522522

523523
it("should handle range that exceeds buffer bounds", function()
524524
local result = selection.get_range_selection(8, 15) -- buffer only has 10 lines
525-
525+
526526
assert(result ~= nil)
527527
assert(result.text == "line 8\nline 9\nline 10")
528528
assert(result.selection.start.line == 7) -- 0-indexed
@@ -548,7 +548,7 @@ describe("Range Selection Tests", function()
548548
local result1 = selection.get_range_selection(nil, 3)
549549
local result2 = selection.get_range_selection(2, nil)
550550
local result3 = selection.get_range_selection(nil, nil)
551-
551+
552552
assert(result1 == nil)
553553
assert(result2 == nil)
554554
assert(result3 == nil)
@@ -574,14 +574,14 @@ describe("Range Selection Tests", function()
574574
return true
575575
end
576576
}
577-
577+
578578
selection.state.tracking_enabled = true
579579
selection.server = mock_server
580580
end)
581581

582582
it("should send range selection successfully", function()
583583
local result = selection.send_at_mention_for_visual_selection(2, 4)
584-
584+
585585
assert(result == true)
586586
assert(mock_server.last_broadcast ~= nil)
587587
assert(mock_server.last_broadcast.event == "at_mentioned")
@@ -607,9 +607,9 @@ describe("Range Selection Tests", function()
607607
isEmpty = false
608608
}
609609
}
610-
610+
611611
local result = selection.send_at_mention_for_visual_selection()
612-
612+
613613
assert(result == true)
614614
assert(mock_server.last_broadcast.params.lineStart == 0)
615615
assert(mock_server.last_broadcast.params.lineEnd == 0)

tests/unit/claudecode_send_command_spec.lua

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe("ClaudeCodeSend Command Range Functionality", function()
3434
notify = spy.new(function() end),
3535
log = { levels = { ERROR = 1, WARN = 2, INFO = 3 } },
3636
deepcopy = function(t) return t end,
37-
tbl_deep_extend = function(behavior, ...)
37+
tbl_deep_extend = function(behavior, ...)
3838
local result = {}
3939
for _, tbl in ipairs({...}) do
4040
for k, v in pairs(tbl) do
@@ -74,7 +74,7 @@ describe("ClaudeCodeSend Command Range Functionality", function()
7474
}
7575

7676
local mock_config = {
77-
apply = function(opts)
77+
apply = function(opts)
7878
return {
7979
auto_start = false,
8080
track_selection = true,
@@ -114,7 +114,7 @@ describe("ClaudeCodeSend Command Range Functionality", function()
114114
-- Load and setup claudecode
115115
claudecode = require("claudecode")
116116
claudecode.setup({})
117-
117+
118118
-- Manually set server state for testing
119119
claudecode.state.server = mock_server
120120
claudecode.state.port = 12345
@@ -128,7 +128,7 @@ describe("ClaudeCodeSend Command Range Functionality", function()
128128
describe("ClaudeCodeSend command", function()
129129
it("should be registered with range support", function()
130130
assert.spy(_G.vim.api.nvim_create_user_command).was_called()
131-
131+
132132
-- Find the ClaudeCodeSend command call
133133
local calls = _G.vim.api.nvim_create_user_command.calls
134134
local claudecode_send_call = nil
@@ -138,107 +138,107 @@ describe("ClaudeCodeSend Command Range Functionality", function()
138138
break
139139
end
140140
end
141-
141+
142142
assert(claudecode_send_call ~= nil, "ClaudeCodeSend command should be registered")
143143
assert(claudecode_send_call.vals[3].range == true, "ClaudeCodeSend should support ranges")
144144
end)
145145

146146
it("should pass range information to selection module when range is provided", function()
147147
assert(command_callback ~= nil, "Command callback should be set")
148-
148+
149149
-- Simulate command called with range
150150
local opts = {
151151
range = 2,
152152
line1 = 5,
153153
line2 = 8
154154
}
155-
155+
156156
command_callback(opts)
157-
157+
158158
assert.spy(mock_selection_module.send_at_mention_for_visual_selection).was_called()
159159
assert(mock_selection_module.last_call.line1 == 5)
160160
assert(mock_selection_module.last_call.line2 == 8)
161161
end)
162162

163163
it("should not pass range information when range is 0", function()
164164
assert(command_callback ~= nil, "Command callback should be set")
165-
165+
166166
-- Simulate command called without range
167167
local opts = {
168168
range = 0,
169169
line1 = 1,
170170
line2 = 1
171171
}
172-
172+
173173
command_callback(opts)
174-
174+
175175
assert.spy(mock_selection_module.send_at_mention_for_visual_selection).was_called()
176176
assert(mock_selection_module.last_call.line1 == nil)
177177
assert(mock_selection_module.last_call.line2 == nil)
178178
end)
179179

180180
it("should not pass range information when range is nil", function()
181181
assert(command_callback ~= nil, "Command callback should be set")
182-
182+
183183
-- Simulate command called without range
184184
local opts = {}
185-
185+
186186
command_callback(opts)
187-
187+
188188
assert.spy(mock_selection_module.send_at_mention_for_visual_selection).was_called()
189189
assert(mock_selection_module.last_call.line1 == nil)
190190
assert(mock_selection_module.last_call.line2 == nil)
191191
end)
192192

193193
it("should exit visual mode and focus terminal on successful send", function()
194194
assert(command_callback ~= nil, "Command callback should be set")
195-
195+
196196
local opts = {
197197
range = 2,
198198
line1 = 5,
199199
line2 = 8
200200
}
201-
201+
202202
command_callback(opts)
203-
203+
204204
assert.spy(_G.vim.api.nvim_feedkeys).was_called()
205205
assert.spy(mock_terminal.open).was_called()
206206
end)
207207

208208
it("should handle server not running", function()
209209
assert(command_callback ~= nil, "Command callback should be set")
210-
210+
211211
-- Simulate server not running
212212
claudecode.state.server = nil
213-
213+
214214
local opts = {
215215
range = 2,
216216
line1 = 5,
217217
line2 = 8
218218
}
219-
219+
220220
command_callback(opts)
221-
221+
222222
assert.spy(_G.vim.notify).was_called()
223223
assert.spy(mock_selection_module.send_at_mention_for_visual_selection).was_not_called()
224224
end)
225225

226226
it("should handle selection module failure", function()
227227
assert(command_callback ~= nil, "Command callback should be set")
228-
228+
229229
-- Mock selection module to return false
230230
mock_selection_module.send_at_mention_for_visual_selection = spy.new(function()
231231
return false
232232
end)
233-
233+
234234
local opts = {
235235
range = 2,
236236
line1 = 5,
237237
line2 = 8
238238
}
239-
239+
240240
command_callback(opts)
241-
241+
242242
assert.spy(mock_selection_module.send_at_mention_for_visual_selection).was_called()
243243
-- Should not exit visual mode or focus terminal on failure
244244
assert.spy(_G.vim.api.nvim_feedkeys).was_not_called()

0 commit comments

Comments
 (0)