feat(session): added SessionLoadPre#19306
Conversation
There was a problem hiding this comment.
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_SESSIONLOADPREenum value and corresponding event name mapping - Modified session file generation to trigger
SessionLoadPreautocmd after settingv: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() |
There was a problem hiding this comment.
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.
| func Test_autocmd_SessLoadPre() | |
| func Test_autocmd_SessionLoadPre() |
| [CODE] | ||
|
|
||
| call writefile(content, 'Xvimrc', 'D') | ||
|
|
There was a problem hiding this comment.
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.
| " Write extra session settings to a separate file that will be sourced | |
| " in addition to Session.vim (to append session variables for this test). |
|
thanks |
|
Thank you!! |
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]>
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]>
#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]>
Closes #19084
A new
SessionLoadPreautocmd is defined and theSession.vimcalls it before attempting to do any work.SessionLoadPrehas access tov:this_session.This is a followup from #19151, sorry for the spam