From 772a838cf612f18c1a01e0c1f2eddf3738cb999c Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Mon, 31 Aug 2026 20:53:11 +0000 Subject: [PATCH] fix COMMIT_EDITMSG last location --- nvim/lua/darcula/autocmds.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/nvim/lua/darcula/autocmds.lua b/nvim/lua/darcula/autocmds.lua index e53e78f..dd12048 100644 --- a/nvim/lua/darcula/autocmds.lua +++ b/nvim/lua/darcula/autocmds.lua @@ -22,16 +22,20 @@ local utils = require("darcula.utils") local group = utils.augroup_with_autocmd( "DarculaAutoCommands", - "BufReadPost", + "BufWinEnter", "*", - function() + function(args) + local bufnr = args.buf + if vim.b[bufnr]._darcula_cursor_restored then + return + end + vim.b[bufnr]._darcula_cursor_restored = true + local ft = vim.bo[bufnr].filetype + if ft == "commit" or ft == "fugitive" or ft == "gitcommit" or ft == "rebase" then + return + end local pos = vim.fn.line('\'"') - if - pos >= 1 and pos <= vim.fn.line("$") and vim.bo.filetype ~= "commit" and - vim.bo.filetype ~= "gitcommit" and - vim.bo.filetype ~= "fugitive" and - vim.bo.filetype ~= "rebase" - then + if pos >= 1 and pos <= vim.fn.line("$") then vim.cmd('normal! g`"') end end