@@ -889,6 +889,16 @@ local function edit_buffer(bufnr, chat_bufnr, action, output_handler, opts)
889889 local final_lines = vim .split (dry_run_result .final_content , " \n " , { plain = true })
890890 api .nvim_buf_set_lines (bufnr , 0 , - 1 , false , final_lines )
891891
892+ local success = success_response (fmt (" Edited `%s` buffer%s" , display_name , extract_explanation (action )))
893+
894+ if approvals :is_approved (chat_bufnr , { tool_name = " insert_edit_into_file" }) then
895+ api .nvim_buf_call (bufnr , function ()
896+ vim .cmd (" silent write" )
897+ end )
898+
899+ return output_handler (success )
900+ end
901+
892902 local should_diff = diff .create (bufnr , diff_id , {
893903 chat_bufnr = chat_bufnr ,
894904 original_content = original_content ,
@@ -904,16 +914,6 @@ local function edit_buffer(bufnr, chat_bufnr, action, output_handler, opts)
904914 ui_utils .scroll_to_line (bufnr , start_line )
905915 end
906916
907- local success = success_response (fmt (" Edited `%s` buffer%s" , display_name , extract_explanation (action )))
908-
909- if approvals :is_approved (chat_bufnr , { tool_name = " insert_edit_into_file" }) then
910- api .nvim_buf_call (bufnr , function ()
911- vim .cmd (" silent write" )
912- end )
913-
914- return output_handler (success )
915- end
916-
917917 if should_diff and opts .require_confirmation_after then
918918 return handle_user_decision ({
919919 diff_id = diff_id ,
0 commit comments