Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #379 clear buffers silently #380

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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