You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
args_allow_single_directory=true, -- boolean Follow normal sesion save/load logic if launched with a single directory as the only argument
114
114
args_allow_files_auto_save=false, -- boolean|function Allow saving a session even when launched with a file argument (or multiple files/dirs). It does not load any existing session first. While you can just set this to true, you probably want to set it to a function that decides when to save a session when launched with file args. See documentation for more detail
115
+
silent_restore=true, -- Suppress extraneous messages and source the whole session, even if there's an error. Set to false to get the line number a restore error
{bypass_session_save_file_types?} (table) List of file types to bypass auto save when the only buffer open is one of the file types listed
24
24
{close_unsupported_windows?} (boolean) Whether to close windows that aren't backed by a real file
25
-
{silent_restore?} (boolean) Whether to restore sessions silently or not
25
+
{silent_restore?} (boolean) Suppress extraneous messages and source the whole session, even if there's an error. Set to false to get the line number of a restore error
---@fieldbypass_session_save_file_types? table List of file types to bypass auto save when the only buffer open is one of the file types listed
76
76
---@fieldclose_unsupported_windows? boolean Whether to close windows that aren't backed by a real file
77
-
---@fieldsilent_restore? boolean Whether to restore sessions silently or not
77
+
---@fieldsilent_restore? boolean Suppress extraneous messages and source the whole session, even if there's an error. Set to false to get the line number of a restore error
---@fieldargs_allow_single_directory? boolean Follow normal sesion save/load logic if launched with a single directory as the only argument
@@ -114,7 +114,7 @@ local luaOnlyConf = {
114
114
control_filename="session_control.json", -- File name of the session control file
115
115
},
116
116
},
117
-
silent_restore=true,
117
+
silent_restore=true,-- Suppress extraneous messages and source the whole session, even if there's an error. Set to false to get the line number of a restore error
118
118
}
119
119
120
120
-- Set default config on plugin load
@@ -939,7 +939,9 @@ function AutoSession.RestoreSessionFile(session_path, show_message)
939
939
localcmd="source " ..vim_session_path
940
940
941
941
ifAutoSession.conf.silent_restorethen
942
-
cmd="silent " ..cmd
942
+
cmd="silent! " ..cmd
943
+
-- clear errors here so we can
944
+
vim.v.errmsg=""
943
945
end
944
946
945
947
-- Set restore_in_progress here so we won't also try to save/load the session if
@@ -959,11 +961,17 @@ function AutoSession.RestoreSessionFile(session_path, show_message)
959
961
-- Clear any saved command line args since we don't need them anymore
960
962
launch_argv=nil
961
963
964
+
ifAutoSession.conf.silent_restoreandvim.v.errmsgandvim.v.errmsg~="" then
965
+
-- we had an error while sourcing silently so surface it
966
+
success=false
967
+
result=vim.v.errmsg
968
+
end
969
+
962
970
ifnotsuccessthen
963
971
Lib.logger.error([[
964
-
Error restoring session! The session might be corrupted.
965
-
Disabling auto save. Please check for errors in your config. Error:
966
-
]] ..result)
972
+
Error restoring session, disabling auto save.
973
+
Set silent_restore = false in the config for a more detailed error message.
0 commit comments