Skip to content

Commit

Permalink
fix: don't auto-center windows containing term buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
willothy authored and cryptomilk committed Sep 16, 2023
1 parent 1e2752a commit edb9a59
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lua/focus/modules/autocmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ function M.setup(config)
return
end

-- Don't center if the previous buffer was a terminal
local prev_win_buf = vim.api.nvim_win_get_buf(previous_win_id)
if vim.bo[prev_win_buf].buftype == 'terminal' then
return
end

local cur_win_pos = vim.fn.win_screenpos(current_win_id)
local prev_win_pos = vim.fn.win_screenpos(previous_win_id)

Expand All @@ -70,7 +76,7 @@ function M.setup(config)
vim.api.nvim_create_autocmd('WinLeave', {
group = augroup,
callback = function(_)
-- Remember the previous window id and cursor position
-- Remember the previous window id
previous_win_id = vim.api.nvim_get_current_win()
end,
desc = 'Save previous window id from split',
Expand Down

0 comments on commit edb9a59

Please sign in to comment.