mirror of
https://github.com/vim/vim.git
synced 2025-08-26 20:03:41 -04:00
patch 9.1.0207: No autocommand when writing session file
Problem: No autocommand when writing session file Solution: Add SessionWritePost autocommand (Colin Kennedy) fixes: ##14242 closes: #14288 Co-authored-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Colin Kennedy <colinvfx@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
63d68c2c21
commit
e5f2280381
@ -1,4 +1,4 @@
|
|||||||
*autocmd.txt* For Vim version 9.1. Last change: 2024 Jan 25
|
*autocmd.txt* For Vim version 9.1. Last change: 2024 Mar 26
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@ -428,6 +428,9 @@ Name triggered by ~
|
|||||||
|
|
||||||
|SessionLoadPost| after loading a session file
|
|SessionLoadPost| after loading a session file
|
||||||
|
|
||||||
|
|SessionWritePost| After writing the session file using
|
||||||
|
the |:mksession| command.
|
||||||
|
|
||||||
|MenuPopup| just before showing the popup menu
|
|MenuPopup| just before showing the popup menu
|
||||||
|CompleteChanged| after Insert mode completion menu changed
|
|CompleteChanged| after Insert mode completion menu changed
|
||||||
|CompleteDonePre| after Insert mode completion is done, before clearing
|
|CompleteDonePre| after Insert mode completion is done, before clearing
|
||||||
@ -1114,6 +1117,9 @@ SafeStateAgain Like SafeState but after processing any
|
|||||||
|
|
||||||
*SessionLoadPost*
|
*SessionLoadPost*
|
||||||
SessionLoadPost After loading the session file created using
|
SessionLoadPost After loading the session file created using
|
||||||
|
the |:mksession| command.
|
||||||
|
*SessionWritePost*
|
||||||
|
SessionWritePost After writing a session file by calling
|
||||||
the |:mksession| command.
|
the |:mksession| command.
|
||||||
*ShellCmdPost*
|
*ShellCmdPost*
|
||||||
ShellCmdPost After executing a shell command with |:!cmd|,
|
ShellCmdPost After executing a shell command with |:!cmd|,
|
||||||
|
@ -5682,6 +5682,7 @@ Select-mode-mapping visual.txt /*Select-mode-mapping*
|
|||||||
Session starting.txt /*Session*
|
Session starting.txt /*Session*
|
||||||
SessionLoad-variable starting.txt /*SessionLoad-variable*
|
SessionLoad-variable starting.txt /*SessionLoad-variable*
|
||||||
SessionLoadPost autocmd.txt /*SessionLoadPost*
|
SessionLoadPost autocmd.txt /*SessionLoadPost*
|
||||||
|
SessionWritePost autocmd.txt /*SessionWritePost*
|
||||||
ShellCmdPost autocmd.txt /*ShellCmdPost*
|
ShellCmdPost autocmd.txt /*ShellCmdPost*
|
||||||
ShellFilterPost autocmd.txt /*ShellFilterPost*
|
ShellFilterPost autocmd.txt /*ShellFilterPost*
|
||||||
SigUSR1 autocmd.txt /*SigUSR1*
|
SigUSR1 autocmd.txt /*SigUSR1*
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
*version9.txt* For Vim version 9.1. Last change: 2024 Mar 03
|
*version9.txt* For Vim version 9.1. Last change: 2024 Mar 26
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@ -41570,6 +41570,7 @@ Functions: ~
|
|||||||
|
|
||||||
Autocommands: ~
|
Autocommands: ~
|
||||||
|
|
||||||
|
|SessionWritePost| after writing the session file |:mksession|
|
||||||
|TermResponseAll| after the terminal response to |t_RV| and others is
|
|TermResponseAll| after the terminal response to |t_RV| and others is
|
||||||
received
|
received
|
||||||
|WinNewPre| before creating a new window
|
|WinNewPre| before creating a new window
|
||||||
|
@ -160,6 +160,7 @@ static struct event_name
|
|||||||
{"SafeState", EVENT_SAFESTATE},
|
{"SafeState", EVENT_SAFESTATE},
|
||||||
{"SafeStateAgain", EVENT_SAFESTATEAGAIN},
|
{"SafeStateAgain", EVENT_SAFESTATEAGAIN},
|
||||||
{"SessionLoadPost", EVENT_SESSIONLOADPOST},
|
{"SessionLoadPost", EVENT_SESSIONLOADPOST},
|
||||||
|
{"SessionWritePost",EVENT_SESSIONWRITEPOST},
|
||||||
{"ShellCmdPost", EVENT_SHELLCMDPOST},
|
{"ShellCmdPost", EVENT_SHELLCMDPOST},
|
||||||
{"ShellFilterPost", EVENT_SHELLFILTERPOST},
|
{"ShellFilterPost", EVENT_SHELLFILTERPOST},
|
||||||
{"SigUSR1", EVENT_SIGUSR1},
|
{"SigUSR1", EVENT_SIGUSR1},
|
||||||
|
@ -1392,6 +1392,8 @@ theend:
|
|||||||
#ifdef FEAT_SESSION
|
#ifdef FEAT_SESSION
|
||||||
vim_free(viewFile);
|
vim_free(viewFile);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
apply_autocmds(EVENT_SESSIONWRITEPOST, NULL, NULL, FALSE, curbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined(FEAT_VIMINFO) || defined(FEAT_SESSION)) || defined(PROTO)
|
#if (defined(FEAT_VIMINFO) || defined(FEAT_SESSION)) || defined(PROTO)
|
||||||
|
@ -4474,4 +4474,60 @@ func Test_autocmd_creates_new_buffer_on_bufleave()
|
|||||||
bw c.txt
|
bw c.txt
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Ensure `expected` was just recently written as a Vim session
|
||||||
|
func s:assert_session_path(expected)
|
||||||
|
call assert_equal(a:expected, v:this_session)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Check for `expected` after a session is written to-disk.
|
||||||
|
func s:watch_for_session_path(expected)
|
||||||
|
execute 'autocmd SessionWritePost * ++once execute "call s:assert_session_path(\"'
|
||||||
|
\ . a:expected
|
||||||
|
\ . '\")"'
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Ensure v:this_session gets the full session path, if explicitly stated
|
||||||
|
func Test_explicit_session_absolute_path()
|
||||||
|
%bwipeout!
|
||||||
|
|
||||||
|
let directory = getcwd()
|
||||||
|
|
||||||
|
let v:this_session = ""
|
||||||
|
let name = "some_file.vim"
|
||||||
|
let expected = fnamemodify(name, ":p")
|
||||||
|
call s:watch_for_session_path(expected)
|
||||||
|
execute "mksession! " .. expected
|
||||||
|
|
||||||
|
call delete(expected)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Ensure v:this_session gets the full session path, if explicitly stated
|
||||||
|
func Test_explicit_session_relative_path()
|
||||||
|
%bwipeout!
|
||||||
|
|
||||||
|
let directory = getcwd()
|
||||||
|
|
||||||
|
let v:this_session = ""
|
||||||
|
let name = "some_file.vim"
|
||||||
|
let expected = fnamemodify(name, ":p")
|
||||||
|
call s:watch_for_session_path(expected)
|
||||||
|
execute "mksession! " .. name
|
||||||
|
|
||||||
|
call delete(expected)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Ensure v:this_session gets the full session path, if not specified
|
||||||
|
func Test_implicit_session()
|
||||||
|
%bwipeout!
|
||||||
|
|
||||||
|
let directory = getcwd()
|
||||||
|
|
||||||
|
let v:this_session = ""
|
||||||
|
let expected = fnamemodify("Session.vim", ":p")
|
||||||
|
call s:watch_for_session_path(expected)
|
||||||
|
mksession!
|
||||||
|
|
||||||
|
call delete(expected)
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
207,
|
||||||
/**/
|
/**/
|
||||||
206,
|
206,
|
||||||
/**/
|
/**/
|
||||||
|
@ -1404,6 +1404,7 @@ enum auto_event
|
|||||||
EVENT_SAFESTATE, // going to wait for a character
|
EVENT_SAFESTATE, // going to wait for a character
|
||||||
EVENT_SAFESTATEAGAIN, // still waiting for a character
|
EVENT_SAFESTATEAGAIN, // still waiting for a character
|
||||||
EVENT_SESSIONLOADPOST, // after loading a session file
|
EVENT_SESSIONLOADPOST, // after loading a session file
|
||||||
|
EVENT_SESSIONWRITEPOST, // after writing a session file
|
||||||
EVENT_SHELLCMDPOST, // after ":!cmd"
|
EVENT_SHELLCMDPOST, // after ":!cmd"
|
||||||
EVENT_SHELLFILTERPOST, // after ":1,2!cmd", ":w !cmd", ":r !cmd".
|
EVENT_SHELLFILTERPOST, // after ":1,2!cmd", ":w !cmd", ":r !cmd".
|
||||||
EVENT_SIGUSR1, // after the SIGUSR1 signal
|
EVENT_SIGUSR1, // after the SIGUSR1 signal
|
||||||
|
Loading…
x
Reference in New Issue
Block a user