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] Can not close last window #442

Open
1 task done
shan-weiqiang opened this issue May 29, 2023 · 4 comments
Open
1 task done

[BUG] Can not close last window #442

shan-weiqiang opened this issue May 29, 2023 · 4 comments

Comments

@shan-weiqiang
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

when switching from one session to another session, with terminal not in vim.o.sessionoptions, the toggleterm window can not be closed
image

Expected Behavior

when switch from one session to another session, toggleterm window should be closed

Steps To Reproduce

  1. install dbsession plugin
  2. save one session and with one toggleterminal
  3. in another session, open toggleterm, the term is the first session's terminal

Environment

- OS:ubuntu 18.04
- neovim version:0.9.0
- Shell:zsh

Anything else?

No response

@skoowoo
Copy link

skoowoo commented May 29, 2023

same problem

@akinsho
Copy link
Owner

akinsho commented May 30, 2023

Based on what you are both reporting it seems that the plugin you are using is trying to close all windows including the last one which is the toggleterm window. This is correctly seen as an error since if you did close all windows neovim would exit. I think this is the same for the standard terminal and I'm not sure this is a problem for this plugin and rather the other plugin should be deleting outdated buffers but not closing windows IMO.

@skoowoo
Copy link

skoowoo commented May 30, 2023

I figure out a way to workaround.

		on_open = function(term)
			-- forced to change the working dir for terminal
			-- This will solve the problem of not updating the directory when switching sessions.
			local cwd = vim.fn.getcwd()
			if cwd ~= term.dir then
				term:change_dir(cwd)
			end
		end,

on_open is the terminal's callback.

@skoowoo
Copy link

skoowoo commented Jun 1, 2023

@akinsho I guess @shan-weiqiang and I have the same root problem, I want to switch the session and open the terminal window and immediately switch to the new session directory instead of continuing in the previous session's directory. So the previous idea was to close all the term windows created before switching sessions and re-create them in the new session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants