Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] "close_unsupported_windows = true" close terminal window #342

Closed
nanozuki opened this issue Aug 5, 2024 · 1 comment
Closed

[BUG] "close_unsupported_windows = true" close terminal window #342

nanozuki opened this issue Aug 5, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@nanozuki
Copy link

nanozuki commented Aug 5, 2024

Describe the bug

The option close_unsupported_windows = true will close the terminal window, event there are "terminal" in sessionoptions.

To Reproduce
Steps to reproduce the behavior:

  1. Open nvim
  2. use tabnew create new tabpage
  3. use terminal open a terminal
  4. use SessionSave create session
  5. exit and reopen nvim
  6. the terminal window is missing.

Expected behavior
Restore the terminal window.

Screenshots
Before close:
image

After restore, terminal is missing:

image

Baseline:

Minimal config to reproduce:

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
require("lazy.minit").repro({
  spec = {
    {
      "rmagatti/auto-session",
      opts = {},
    },
  },
})

vim.o.sessionoptions = "buffers,curdir,folds,help,tabpages,winsize,resize,winpos,terminal,globals"
vim.o.showtabline = 2
vim.o.background = "dark"

Save this file to repro.lua, use nvim -u repro.lua to open nvim with this config.

Additional context

Because there is a "terminal" option in sessionoptions, I think the terminal window shouldn't be close when this option is active.

I use this function to clean buffers before, maybe helps you:

local function clean_buffers()
  local bufs = vim.api.nvim_list_bufs()
  for _, buf in ipairs(bufs) do
    local name = vim.api.nvim_buf_get_name(buf)
    local type = vim.api.nvim_get_option_value('buftype', { buf = buf })
    if name ~= '' and type ~= '' and type ~= 'terminal' then
      vim.api.nvim_buf_delete(buf, {})
    end
  end
end
@cameronr
Copy link
Collaborator

cameronr commented Aug 5, 2024

Great catch! I'll get a fix out. thanks!

cameronr added a commit that referenced this issue Aug 6, 2024
fix: #342 don't close terminal windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants