From 6159f7cc992faeb2d6aea14bda6ef555547d7b88 Mon Sep 17 00:00:00 2001 From: Cameron Ring Date: Thu, 19 Sep 2024 15:29:05 -0700 Subject: [PATCH] fix: #379 clear buffers silently --- README.md | 2 +- lua/auto-session/init.lua | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ab85dcd..d3b7ad4 100644 --- a/README.md +++ b/README.md @@ -226,7 +226,7 @@ It's disabled by default, but when enabled it works as follows: - DirChangedPre (before the cwd actually changes): - Save the current session - - Clear all buffers `%bd!`. This guarantees buffers don't bleed to the + - Clear all buffers `%bw!`. This guarantees buffers don't bleed to the next session. - Clear jumps. Also done so there is no bleeding between sessions. - Run the `pre_cwd_changed` hook diff --git a/lua/auto-session/init.lua b/lua/auto-session/init.lua index 65fbed6..a792235 100644 --- a/lua/auto-session/init.lua +++ b/lua/auto-session/init.lua @@ -646,16 +646,16 @@ function AutoSession.RestoreSessionFile(session_path, show_message) AutoSession.restore_in_progress = true -- Clear the buffers and jumps - vim.cmd "%bw!" - vim.cmd "clearjumps" + vim.cmd "silent %bw!" + vim.cmd "silent clearjumps" ---@diagnostic disable-next-line: param-type-mismatch local success, result = pcall(vim.cmd, "silent " .. cmd) -- normal restore failed, source again but with silent! to restore as much as possible if not success and Config.continue_restore_on_error then - vim.cmd "%bw!" - vim.cmd "clearjumps" + vim.cmd "silent %bw!" + vim.cmd "silent clearjumps" -- don't capture return values as we'll use success and result from the first call ---@diagnostic disable-next-line: param-type-mismatch