@@ -48,7 +48,6 @@ function M.setup_autocmds(windows)
48
48
group = group ,
49
49
buffer = windows .output_buf ,
50
50
callback = function ()
51
- M .setup_placeholder (windows )
52
51
vim .cmd (' stopinsert' )
53
52
end
54
53
})
@@ -57,7 +56,18 @@ function M.setup_autocmds(windows)
57
56
vim .api .nvim_create_autocmd (' WinEnter' , {
58
57
group = group ,
59
58
buffer = windows .input_buf ,
60
- callback = function () vim .cmd (' startinsert' ) end
59
+ callback = function ()
60
+ -- Don't automatically enter insert mode when switching windows
61
+ -- Check if the buffer has content
62
+ local lines = vim .api .nvim_buf_get_lines (windows .input_buf , 0 , - 1 , false )
63
+ if # lines == 1 and lines [1 ] == " " then
64
+ -- Only show placeholder if the buffer is empty
65
+ M .setup_placeholder (windows )
66
+ else
67
+ -- Clear placeholder if there's text in the buffer
68
+ vim .api .nvim_buf_clear_namespace (windows .input_buf , vim .api .nvim_create_namespace (' input-placeholder' ), 0 , - 1 )
69
+ end
70
+ end
61
71
})
62
72
63
73
vim .api .nvim_create_autocmd ({ ' TextChanged' , ' TextChangedI' }, {
@@ -198,6 +208,15 @@ function M.setup_keymaps(windows)
198
208
vim .keymap .set (' i' , window_keymap .mention_file , function ()
199
209
require (' goose.core' ).add_file_to_context ()
200
210
end , { buffer = windows .input_buf , silent = true })
211
+
212
+ -- Add toggle pane keymapping for both buffers in normal and insert mode
213
+ vim .keymap .set ({ ' n' , ' i' }, window_keymap .toggle_pane , function ()
214
+ api .toggle_pane ()
215
+ end , { buffer = windows .input_buf , silent = true })
216
+
217
+ vim .keymap .set ({ ' n' , ' i' }, window_keymap .toggle_pane , function ()
218
+ api .toggle_pane ()
219
+ end , { buffer = windows .output_buf , silent = true })
201
220
end
202
221
203
222
return M
0 commit comments