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

Use the global working directory when autosaving on close [FEATURE] #189

Open
TC72 opened this issue Dec 6, 2022 · 3 comments
Open

Use the global working directory when autosaving on close [FEATURE] #189

TC72 opened this issue Dec 6, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@TC72
Copy link

TC72 commented Dec 6, 2022

My workflow involves using tabs which each have their own working directory set using :tcd.

Right now if I :qa to quit and leave all my tabs intact then auto-session saves to a session based on the cwd of whichever tab I quit from. This would also be an issue if someone used :lcd to set the current working directory of a window.

I can see this is because Lib.escaped_session_name_from_cwd() uses vim.fn.getcwd(). When called with no argument it tries to get the cwd of the window first, if that's not set then the cwd of the tab, if that's not set then the global cwd.

The simple solution is to change the code to use vim.fn.getcwd( -1,-1) which would return the global working directory which only gets changed by using :cd. (This might not be the right place, I had a quick look through the code and this seems like where the cwd is chosen.)

I thought I had configured the plugin incorrectly as every time I left from a tab other than the first one I would lose my session. After looking at all the sessions being saved I figured out what was happening.

@TC72 TC72 added the enhancement New feature or request label Dec 6, 2022
@rmagatti
Copy link
Owner

Looks like a duplicate of this maybe?
#76

@TC72
Copy link
Author

TC72 commented Dec 12, 2022

Looks like a duplicate of this maybe? #76

Thanks, I did find that one before posting but the use cases are different. The other issue is using multiple tabs to handle different projects, I'm using tabs to have different directories as the working directory inside a single project.

But after reading that issue again, I think the solution would be the same for both of them, So I'll start posting there.

@TC72
Copy link
Author

TC72 commented Oct 28, 2023

I'm going to come back to this issue as #76 is different.
Will now replace every instance of vim.fn.getcwd() with vim.fn.getcwd( -1,-1) and see if it breaks anything.

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

No branches or pull requests

2 participants