Skip to content

feat(session): added SessionLoadPre#19306

Closed
ColinKennedy wants to merge 1 commit intovim:masterfrom
ColinKennedy:19084-add_SessionLoadPre_autocmd
Closed

feat(session): added SessionLoadPre#19306
ColinKennedy wants to merge 1 commit intovim:masterfrom
ColinKennedy:19084-add_SessionLoadPre_autocmd

Conversation

@ColinKennedy
Copy link
Contributor

Closes #19084

A new SessionLoadPre autocmd is defined and the Session.vim calls it before attempting to do any work. SessionLoadPre has access to v:this_session.

This is a followup from #19151, sorry for the spam

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements a new SessionLoadPre autocmd event that fires before a session file begins loading, complementing the existing SessionLoadPost event.

Changes:

  • Added EVENT_SESSIONLOADPRE enum value and corresponding event name mapping
  • Modified session file generation to trigger SessionLoadPre autocmd after setting v:this_session
  • Added comprehensive test coverage verifying the event fires before session variables are set
  • Updated documentation across multiple files to describe the new autocmd event

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/vim.h Adds EVENT_SESSIONLOADPRE enum constant for the new autocmd event
src/autocmd.c Registers the "SessionLoadPre" event name in the event lookup table
src/session.c Inserts doautoall SessionLoadPre command in generated session files
src/testdir/test_autocmd.vim Adds test verifying SessionLoadPre fires before SessionLoadPost and session variables are set
runtime/doc/autocmd.txt Documents the new SessionLoadPre autocmd event with its trigger condition
runtime/doc/starting.txt Updates session loading documentation to mention SessionLoadPre
runtime/doc/options.txt Adds SessionLoadPre to the alphabetical list of autocmd events

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

only
endfunc

func Test_autocmd_SessLoadPre()
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

Function name uses abbreviated 'Sess' instead of 'Session' which is inconsistent with the actual autocmd event name 'SessionLoadPre'. Consider renaming to 'Test_autocmd_SessionLoadPre' for clarity and consistency.

Suggested change
func Test_autocmd_SessLoadPre()
func Test_autocmd_SessionLoadPre()

Copilot uses AI. Check for mistakes.
[CODE]

call writefile(content, 'Xvimrc', 'D')

Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

The filename 'Sessionx.vim' is unclear. The 'x' suffix doesn't convey its purpose (appending session variables). Consider a more descriptive name like 'SessionAppend.vim' or add a comment explaining why this separate file is needed.

Suggested change
" Write extra session settings to a separate file that will be sourced
" in addition to Session.vim (to append session variables for this test).

Copilot uses AI. Check for mistakes.
@chrisbra
Copy link
Member

thanks

@ColinKennedy
Copy link
Contributor Author

Thank you!!

zeertzjq added a commit to zeertzjq/neovim that referenced this pull request Feb 26, 2026
Problem:  Not possible to know when a session will be loaded.
Solution: Add the SessionLoadPre autocommand (Colin Kennedy).

fixes:  vim/vim#19084
closes: vim/vim#19306

vim/vim@1c0d468

Co-authored-by: Colin Kennedy <[email protected]>
zeertzjq added a commit to zeertzjq/neovim that referenced this pull request Feb 26, 2026
Problem:  Not possible to know when a session will be loaded.
Solution: Add the SessionLoadPre autocommand (Colin Kennedy).

fixes:  vim/vim#19084
closes: vim/vim#19306

vim/vim@1c0d468

Co-authored-by: Colin Kennedy <[email protected]>
zeertzjq added a commit to neovim/neovim that referenced this pull request Feb 26, 2026
#38071)

Problem:  Not possible to know when a session will be loaded.
Solution: Add the SessionLoadPre autocommand (Colin Kennedy).

fixes:  vim/vim#19084
closes: vim/vim#19306

vim/vim@1c0d468

Co-authored-by: Colin Kennedy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add SessionLoadPre autocmd

3 participants