From e20855a23273d0b0b3d603d65f39d2263a60a073 Mon Sep 17 00:00:00 2001 From: Tim Macfarlane Date: Thu, 15 Jul 2021 10:24:29 +0200 Subject: [PATCH] preseve edit marks from before save --- lua/autosave/modules/autocmds.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lua/autosave/modules/autocmds.lua b/lua/autosave/modules/autocmds.lua index 89bcaba..b9370c6 100644 --- a/lua/autosave/modules/autocmds.lua +++ b/lua/autosave/modules/autocmds.lua @@ -30,7 +30,14 @@ local function actual_save() -- might use update, but in that case it can't be checekd if a file was modified and so it will always -- print opts["execution_message"] if (api.nvim_eval([[&modified]]) == 1) then + local first_char_pos = vim.fn.getpos("'[") + local last_char_pos = vim.fn.getpos("']") + cmd("silent! write") + + vim.fn.setpos("'[", first_char_pos) + vim.fn.setpos("']", last_char_pos) + if (get_modified() == nil or get_modified() == false) then set_modified(true) end