Skip to content

Commit

Permalink
Merge pull request #380 from cameronr/main
Browse files Browse the repository at this point in the history
fix: #379 clear buffers silently
  • Loading branch information
cameronr authored Sep 20, 2024
2 parents 51e2693 + 6159f7c commit 0caedb8
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 0caedb8

Please sign in to comment.