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

Unify session selection logic, Fixes #287 #315

Merged
merged 6 commits into from
Jul 7, 2024

Conversation

cameronr
Copy link
Collaborator

@cameronr cameronr commented Jul 1, 2024

Unify the session loading logic between Telesecop session-lens and AutoSession search so that we always use the session file to load the session (vs relying on changing directory). Set a flag to make sure cwd_change_handling (if enabled) doesn't also try to restore the session This also fixes a session load failure when a session with a git branch name is selected from Telescope session-lens or Autosession search.

Removed the non-functional (as far as I can see) code for buftypes_to_ignore. That code would not bwipeout a buffer if it matched but the buffers get wiped out by the sourcing the session file anyway and having that code generates an error when the buffer is opened in another process which interrupts the session swap. Made the option deprecated and asked anyone using it to report it on GH.

Unify the session loading logic between Telesecop session-lens and
AutoSession search so that we always use the session file to load the
session (vs relying on changing directory). Set a flag to make sure
cwd_change_handling (if enabled) doesn't also try to restore the session
This also fixes a session load failure when a session with a git branch
name is selected from Telescope session-lens or Autosession search.

Removed the non-functional (as far as I can see) code for
buftypes_to_ignore. That code would not bwipeout a buffer if it matched
but the buffers get wiped out by the sourcing the session file anyway
and having that code generates an error when the buffer is opened in
another process which interrupts the session swap. Made the option
deprecated and asked anyone using it to report it on GH.
@cameronr
Copy link
Collaborator Author

cameronr commented Jul 1, 2024

Also fixes #314

The session check works as follows:
For each session file, first check that it's not a directory.
Then check if it ends in x.vim. If it doesn't, then return true.
If it does, if the first line contains the word
"SessionLoad" then return true and false otherwise.

This will include valid session files that happen to end in x and not
include the *x.vim session files neovim creates for custom user commands
saved with the session.
@cameronr
Copy link
Collaborator Author

cameronr commented Jul 2, 2024

Just added a fix for #295 as well

@rmagatti rmagatti self-requested a review July 2, 2024 22:30
Copy link
Owner

@rmagatti rmagatti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just a comment on path joining regarding Windows users 🙏

lua/auto-session/init.lua Outdated Show resolved Hide resolved
Will have to look at other uses of '/' at a later time
@cameronr
Copy link
Collaborator Author

cameronr commented Jul 5, 2024

Should be all set now. thanks!

@tan-wei
Copy link

tan-wei commented Jul 5, 2024

Is these PR will fix this? Thanks very much.

Seems now it is a proper time to fix this.

@cameronr
Copy link
Collaborator Author

cameronr commented Jul 5, 2024

@tan-wei Yes, this should fix loading a git session from either :Autosession search or :Telescope session-lens. Once it's integrated, give it a shot and let us know

@tan-wei
Copy link

tan-wei commented Jul 5, 2024

@tan-wei Yes, this should fix loading a git session from either :Autosession search or :Telescope session-lens. Once it's integrated, give it a shot and let us know

Wow, great!

Copy link
Owner

@rmagatti rmagatti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great now, thanks again for the work put into this 🤜🤛

@rmagatti rmagatti merged commit d5f5c18 into rmagatti:main Jul 7, 2024
@tan-wei
Copy link

tan-wei commented Jul 7, 2024

Great. Seems all works well now!!!

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

Successfully merging this pull request may close these issues.

3 participants