[vim/vim] feat(session): added SessionLoadPre (PR #19306)

1 view
Skip to first unread message

Colin Kennedy

unread,
Feb 1, 2026, 11:29:44 AMFeb 1
to vim/vim, Subscribed

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


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/19306

Commit Summary

  • 77c737e feat(session): added SessionLoadPre

File Changes

(7 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19306@github.com>

Copilot

unread,
12:56 PM (3 hours ago) 12:56 PM
to vim/vim, Subscribed

@Copilot commented on this pull request.

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.


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.Message ID: <vim/vim/pull/19306/review/3827532381@github.com>

Reply all
Reply to author
Forward
0 new messages