Skip to content

Commit

Permalink
fix(autocmds): dont jump to last loc in gitcommit buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 30, 2023
1 parent 75d029c commit 65c70f6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lua/lazyvim/config/autocmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@ vim.api.nvim_create_autocmd({ "VimResized" }, {
vim.api.nvim_create_autocmd("BufReadPost", {
group = augroup("last_loc"),
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local lcount = vim.api.nvim_buf_line_count(0)
local exclude = { "gitcommit" }
local buf = vim.api.nvim_get_current_buf()
if vim.tbl_contains(exclude, vim.bo[buf].filetype) then
return
end
local mark = vim.api.nvim_buf_get_mark(buf, '"')
local lcount = vim.api.nvim_buf_line_count(buf)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
pcall(vim.api.nvim_win_set_cursor, buf, mark)
end
end,
})
Expand Down

0 comments on commit 65c70f6

Please sign in to comment.