Skip to content

Commit cb3f35a

Browse files
committed
fix: address Copilot feedback on diff tests and implementation
- Add temp_file field to mocked _open_native_diff implementation - Ensure error case returns temp_file = nil explicitly - Add comprehensive error validation in tests - Improve test robustness and consistency docs: add terminal-based diff acceptance/rejection option - Document that users can accept/reject diffs from Claude Code terminal - Provide alternative workflow for terminal-focused users Change-Id: I5bee1fffb5cec40d0d593795ec1d8bb2dd2208be Signed-off-by: Thomas Kosiewski <[email protected]>
1 parent 99fbb8e commit cb3f35a

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ Both methods signal Claude Code to apply the changes to your file, after which t
151151

152152
When you reject changes, the diff view closes and the original file remains unchanged.
153153

154+
### Accepting/Rejecting from Claude Code Terminal
155+
156+
You can also navigate to the Claude Code terminal window and accept or reject diffs directly from within Claude's interface. This provides an alternative way to manage diffs without using the Neovim-specific keymaps.
157+
154158
### How It Works
155159

156160
The plugin uses a signal-based approach where accepting or rejecting a diff sends a message to Claude Code rather than directly modifying files. This ensures consistency and allows Claude Code to handle the actual file operations while the plugin manages the user interface and buffer reloading.

lua/claudecode/diff.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ function M._open_native_diff(old_file_path, new_file_path, new_file_contents, ta
231231
local new_filename = vim.fn.fnamemodify(new_file_path, ":t") .. ".new"
232232
local tmp_file, err = create_temp_file(new_file_contents, new_filename)
233233
if not tmp_file then
234-
return { provider = "native", tab_name = tab_name, success = false, error = err }
234+
return { provider = "native", tab_name = tab_name, success = false, error = err, temp_file = nil }
235235
end
236236

237237
local target_win = find_main_editor_window()

tests/unit/diff_spec.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ describe("Diff Module", function()
9292
expect(result.success).to_be_false()
9393
expect(result.error).to_be_string()
9494
expect(result.error:find("Failed to create temporary file", 1, true)).not_to_be_nil()
95+
expect(result.temp_file).to_be_nil() -- Ensure no temp_file is created on failure
9596

9697
rawset(io, "open", old_io_open)
9798
end)
@@ -263,6 +264,7 @@ describe("Diff Module", function()
263264
success = true,
264265
provider = "native",
265266
tab_name = tab_name,
267+
temp_file = "/mock/temp/file.new",
266268
}
267269
end
268270

0 commit comments

Comments
 (0)