mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-31 08:04:39 +02:00
fix(autocmds): dont jump to last loc in gitcommit buffers
This commit is contained in:
parent
75d029c35b
commit
65c70f6ad7
1 changed files with 8 additions and 3 deletions
|
@ -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,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue