fix(autocmds): extra check that we didn't do last_loc more than once for the buffer

This commit is contained in:
Folke Lemaitre
2023-10-09 20:11:05 +02:00
parent 6b857f1de6
commit 5d44c976a7

View File

@ -34,9 +34,10 @@ vim.api.nvim_create_autocmd("BufReadPost", {
callback = function(event) callback = function(event)
local exclude = { "gitcommit" } local exclude = { "gitcommit" }
local buf = event.buf local buf = event.buf
if vim.tbl_contains(exclude, vim.bo[buf].filetype) then if vim.tbl_contains(exclude, vim.bo[buf].filetype) or vim.b[buf].lazyvim_last_loc then
return return
end end
vim.b[buf].lazyvim_last_loc = true
local mark = vim.api.nvim_buf_get_mark(buf, '"') local mark = vim.api.nvim_buf_get_mark(buf, '"')
local lcount = vim.api.nvim_buf_line_count(buf) local lcount = vim.api.nvim_buf_line_count(buf)
if mark[1] > 0 and mark[1] <= lcount then if mark[1] > 0 and mark[1] <= lcount then