fix: multiple navigation fixes for splits/popup terminal

chore: update Keybinds.md

more navigation fixes (primarly disabling mouse when terminal is open)

rm session
This commit is contained in:
Wesley van Tilburg
2026-03-14 13:56:36 +01:00
committed by Wesley van Tilburg
parent bb91392a21
commit 6dfbb4ec22
5 changed files with 213 additions and 185 deletions

View File

@@ -66,6 +66,22 @@ vim.api.nvim_create_autocmd("FileType", {
local dir = oil.get_current_dir()
if not dir then return end
local filepath = dir .. entry.name
local abs_path = vim.fn.fnamemodify(filepath, ":p")
-- Check if file is already tracked in any window's tab list
for win, bufs in pairs(_G.win_bufs or {}) do
if vim.api.nvim_win_is_valid(win) then
for _, buf in ipairs(bufs) do
if vim.api.nvim_buf_is_valid(buf)
and vim.fn.fnamemodify(vim.api.nvim_buf_get_name(buf), ":p") == abs_path then
vim.api.nvim_set_current_win(win)
vim.api.nvim_set_current_buf(buf)
return
end
end
end
end
local target_win = nil
-- Try last focused code window
@@ -92,7 +108,6 @@ vim.api.nvim_create_autocmd("FileType", {
if target_win then
vim.api.nvim_set_current_win(target_win)
-- Remember blank buffer to clean up after opening
local old_buf = vim.api.nvim_get_current_buf()
local is_blank = vim.api.nvim_buf_get_name(old_buf) == ""
and not vim.bo[old_buf].modified
@@ -100,7 +115,16 @@ vim.api.nvim_create_autocmd("FileType", {
and vim.api.nvim_buf_get_lines(old_buf, 0, 1, false)[1] == ""
vim.cmd.edit(vim.fn.fnameescape(filepath))
if is_blank and old_buf ~= vim.api.nvim_get_current_buf() then
vim.api.nvim_buf_delete(old_buf, { force = true })
local in_use = false
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
if vim.api.nvim_win_get_buf(win) == old_buf then
in_use = true
break
end
end
if not in_use then
vim.api.nvim_buf_delete(old_buf, { force = true })
end
end
else
-- No code window exists: create a split to the right