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
https://github.com/vim/vim/pull/19306
(7 files)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@Copilot commented on this pull request.
This PR implements a new SessionLoadPre autocmd event that fires before a session file begins loading, complementing the existing SessionLoadPost event.
Changes:
EVENT_SESSIONLOADPRE enum value and corresponding event name mappingSessionLoadPre autocmd after setting v:this_sessionCopilot 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.
In src/testdir/test_autocmd.vim:
> @@ -1091,6 +1091,71 @@ func Test_BufEnter() only endfunc +func Test_autocmd_SessLoadPre()
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()
In src/testdir/test_autocmd.vim:
> +
+ func! OnSessionLoadPost()
+ call Assert(exists('g:session_loaded_var'),
+ \ 'SessionLoadPost: var IS set')
+ echomsg "SessionLoadPost DONE"
+ endfunc
+ au SessionLoadPost * call OnSessionLoadPost()
+
+ func! WriteErrors()
+ call writefile([execute("messages")], "XerrorsPost")
+ endfunc
+ au VimLeave * call WriteErrors()
+ [CODE]
+
+ call writefile(content, 'Xvimrc', 'D')
+
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).
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()