Skip to content

Commit

Permalink
fix: #379 clear buffers silently
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronr committed Sep 19, 2024
1 parent 51e2693 commit 6159f7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lua/auto-session/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6159f7c

Please sign in to comment.