@@ -111,6 +111,14 @@ local function is_buffer_dirty(file_path)
111
111
return is_dirty , nil
112
112
end
113
113
114
+ --- Restore window layout by delegating to terminal module
115
+ local function restore_window_layout ()
116
+ local ok , terminal = pcall (require , " claudecode.terminal" )
117
+ if ok and terminal .restore_window_layout then
118
+ terminal .restore_window_layout ()
119
+ end
120
+ end
121
+
114
122
--- Setup the diff module
115
123
--- @param user_config table ? The configuration passed from init.lua
116
124
function M .setup (user_config )
@@ -369,6 +377,8 @@ function M._resolve_diff_as_saved(tab_name, buffer_id)
369
377
if diff_data .target_window and vim .api .nvim_win_is_valid (diff_data .target_window ) then
370
378
vim .api .nvim_set_current_win (diff_data .target_window )
371
379
vim .cmd (" diffoff" )
380
+ -- Restore proper window layout after closing diff
381
+ restore_window_layout ()
372
382
end
373
383
374
384
-- Create MCP-compliant response
@@ -678,6 +688,8 @@ function M._cleanup_diff_state(tab_name, reason)
678
688
vim .api .nvim_win_call (diff_data .target_window , function ()
679
689
vim .cmd (" diffoff" )
680
690
end )
691
+ -- Restore proper window layout after cleanup
692
+ restore_window_layout ()
681
693
end
682
694
683
695
-- Remove from active diffs
@@ -1016,6 +1028,8 @@ function M.deny_current_diff()
1016
1028
if target_window and vim .api .nvim_win_is_valid (target_window ) then
1017
1029
vim .api .nvim_set_current_win (target_window )
1018
1030
vim .cmd (" diffoff" )
1031
+ -- Restore proper window layout after rejecting diff
1032
+ restore_window_layout ()
1019
1033
end
1020
1034
1021
1035
M ._resolve_diff_as_rejected (tab_name )
0 commit comments