persistence.nvim
persistence.nvim copied to clipboard
feat(config): add `branch="any"` option to configure fallback behavior
This PR adds a new branch="any" configuration option that enables more flexible session fallback behavior.
Why? I prefer to always fall back to a known session, I don't want a newly created branch to negate my previously saved sessions.
Changes
-
New config option:
branch="any"allows sessions to fall back to the most recent session from any branch -
Backward compatible: Default behavior (
branch=true) remains unchanged - Smart fallback: Falls back to the most recently modified session file from any branch when current branch has no session
Configuration Options
-
branch = false: Single session per directory, not branch-specific -
branch = true(default): Branch-specific session, won't fall back to other branches -
branch = "any": Branch-specific session, falls back to any other branch if current branch has no session
Implementation
Added find_any_branch_session() function that:
- Finds all session files for the current directory across all branches
- Sorts them by modification time (most recent first)
- Returns the most recently modified session file
This is useful for workflows where you switch between branches frequently and want to restore your work even when the current branch doesn't have a saved session yet.