-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add a "exist_in_session" config for #121 #122
Conversation
What is the difference between |
In my opinion, |
If it doesn't work, it probably a bug. |
|
I did a simple refactor, you can see if it can be merged |
I like it, thanks! |
This change seems to have broken the behavior of |
I think this new behavior is more expected... What was your workflow? |
This reverts commit b552ee8.
Create a session in a directory and use it. Close the session and open a different file in the same directory but don't want to overwrite the old session. Close that one file and then be able to restore the old session. The new behavior will autosave a new session with just the one file and lose the previous session that I want to go back to. I don't want an autosave unless I have activated the session which is the old behavior. |
I would suggest to implement this behavior locally. You can have your custom autosave via autocmd that saves only if a special variable is set. |
Seems like it would make more sense to restore the old behavior and add a new option like the suggested |
My concern is having many options with similar names :( And I'm sorry it's caused a breaking change for you. I though that it was a bug. Reminds me this 😅 But I personally think that this new behavior is more expected. Although I would remove all these parameters altogether... But users will hate me. |
Haha, make sense. Thanks. |
It causes the same issue for me, but I have quite a valid use case (IMHO of course 😉) which (I hope) is a good reason to revert this change after all... First some context; I'm using a wide screens with 4 windows next to each other, so being able to resume a session saves me a ton of time searching and opening all the files I was working on. Now lately I noticed that suddenly one of my session configs was gone and it now tried to open single file in a single window called When debugging and reading this issue I now understand what is happening. I open k9s from wherever I am in my terminal to connect to Kubernetes. And every now and then I then open a deployment or secret from within So I am pretty sure I can think of more of these kind of uses. I also have a similar workflow when editing a file from Lazygit which then also opens the file in So can you please reconsider if this indeed the expected behavior, as to me this feels like a very unexpected side effect that I would actually call a bug. Thanks! |
If you set local au_group =
vim.api.nvim_create_augroup("NvimSessionAuGroup", { clear = true })
vim.g.session_active = false
vim.api.nvim_create_autocmd({ "User" }, {
pattern = "SessionLoadPost",
group = au_group,
callback = function()
vim.g.session_active = true
end,
})
vim.api.nvim_create_autocmd({ "BufWritePre", "VimLeavePre" }, {
group = au_group,
callback = function()
if vim.g.session_active == true then
require("session_manager").save_current_session()
end
end,
}) |
@ranebrown thanks for the snippet! At least I now have a way around it, yet I'd still argue the current behavior has a bug that should be fixed. Both |
@svanharmelen hmm... But it saves the session after k9s or Lazygit? It should save only if you already have a session with this name. |
Is saves the session using the folder name from which I started one of those tools (which will be the CWD for the tools). Say I'm working on So if from that terminal I now start one of those tools it overwrites the session that I have for that folder every time I do open or edit in file in one of the tools. |
Got it! |
That would be a great solution indeed! |
Any chance you could open a PR for it? |
If you can point me to that check I can make a PR for it. |
Sure, it's this line:
|
Hmm... That seems a bit limiting as I tent to use an alias like Hoped this was a way to tell if a session was loaded by using something that the plugin sets when it finished loading a session. But I guess that is more or less the Yet I do wonder what @Parsifa1 actually wanted to fix? As I've read (and read again) the info given in #121 but I fail to fully understand if the changes made are indeed needed for his use case.
If I read and understand this comment correctly then I don't see the issue with adding something that checks if a session was actually loaded. That will still allow you to only manually create sessions (I only manually create sessions as well) and it also doesn't prevent to save updates to already existing sessions. The only thing that is needed is that you have loaded a session. But I'm getting the impression @Parsifa1 doesn't want to load the session but does want the (not-loaded) session to be updated automatically. While I appreciate you (@Parsifa1) may feel otherwise, to me that feels weird and unexpected and I wonder if that is indeed the intention of this setting @Shatur? But besides that, am I correct in my assumptions @Parsifa1? And if so, do you agree that maybe using one of the many ways to load a session make more sense than the current behavior (also given the issues we discussed above)? |
Good points. Now I think that we should just revert the change. What I disliked about the variable is that you may change your current directory and it will save the session despite you are no longer inside the session. I wondering if we could store the last loaded session name and on autosave check if it matches the current?.. |
@svanharmelen In my opinion I'm using it in my config, I used it just like a cli in neovim, which maybe really strange :X |
But I think we should provide a variety of possible implementations of |
My use case will be automatically saved when you exit the |
I think it is reasonable to fall back to, or at least retain, the old behavior. After all, there are many other plugins based on the old behavior such as this |
It seems that it's still works in other plugins :) |
Thanks for your replies @Parsifa1! And reading this:
It feels like you and @Shatur mean the same thing here:
I think I can achieve that by restoring the "old" behavior based on the code in this PR work and adding a bit of adjusted logic back from the code that was there before. Looking at your dotfiles I see you are actually loading a session, so checking for a loaded session should not impact your workflow but it should fix other workflows. Do need to find some time for it as I need to do some actual work as well today 😉 But I will try to create a PR for it so we can all have a look if that might be the correct solution that will fit both use cases. |
this may be a good idea ,can be called |
Yeah I'm thinking about something in that direction. Yet I don't intent to add a new config option but instead "fix" the one we already have and then suggest we never tough it again 😂 And if people do want additional uses, I'm with @Shatur that just keep adding very specific config options isn't a good idea and people should instead create an |
@Shatur please checkout (and maybe test) #134 as I believe this will solve the issues discussed here (and fix a small additional bug), including that it will now only auto save things related to the loaded session. So if you leave the directory related to your loaded session, it will not auto save from there as well. I believe this combines and solves the two issues/goals, so this should be a working solution for @Parsifa1 (and others) as well. |
as title