From 7db810c04fc0d89fcb42fe87f5a94ba6650cb8c9 Mon Sep 17 00:00:00 2001 From: Dominik Polakovics Date: Wed, 11 Dec 2024 01:24:17 +0100 Subject: [PATCH] feat: change the loop so it asks first if you want to paste a file --- lua/chatgpt_nvim/init.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lua/chatgpt_nvim/init.lua b/lua/chatgpt_nvim/init.lua index 846c843..b905ea8 100644 --- a/lua/chatgpt_nvim/init.lua +++ b/lua/chatgpt_nvim/init.lua @@ -46,6 +46,12 @@ function M.run_chatgpt_command() vim.fn.input("") -- wait for user to press Enter while true do + local another = vim.fn.input("Do you want to paste another file? (y/n): ") + if another:lower() ~= "y" then + handler.finish() + break + end + -- Ask user for filepath local filepath = "" while true do @@ -77,12 +83,6 @@ function M.run_chatgpt_command() handler.write_file(filepath, filecontent) print("Wrote file: " .. filepath) - - local another = vim.fn.input("Do you want to paste another file? (y/n): ") - if another:lower() ~= "y" then - handler.finish() - break - end end end