From a5a7192c53d942423c059545b2034b1016d8effa Mon Sep 17 00:00:00 2001 From: Young Date: Tue, 14 Nov 2023 22:33:01 +0800 Subject: [PATCH] Make diff more friendly --- lua/chatgpt/code_edits.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/chatgpt/code_edits.lua b/lua/chatgpt/code_edits.lua index 2200916f..07202bf3 100644 --- a/lua/chatgpt/code_edits.lua +++ b/lua/chatgpt/code_edits.lua @@ -310,7 +310,12 @@ M.edit_with_instructions = function(output_lines, bufnr, selection, ...) for _, winid in ipairs({ input_window.winid, output_window.winid }) do vim.api.nvim_set_current_win(winid) if diff_mode then + -- set local wrap to be previous option to make it mroe readable(wrap=true is often more readable in diff mode). + local previous_wrap = vim.o.wrap vim.api.nvim_command("diffthis") + if vim.o.wrap ~= previous_wrap then + vim.o.wrap = previous_wrap + end else vim.api.nvim_command("diffoff") end