Skip to content

fix: fallback to last buffer if window empty (#66)#74

Merged
stevearc merged 1 commit intostevearc:masterfrom
jpetrie:master
Jun 1, 2025
Merged

fix: fallback to last buffer if window empty (#66)#74
stevearc merged 1 commit intostevearc:masterfrom
jpetrie:master

Conversation

@jpetrie
Copy link
Copy Markdown
Contributor

@jpetrie jpetrie commented Apr 11, 2025

If curwin is nil during session load (which can happen when the buffer in the only window was filtered out of the session), fall back to opening the last restored buffer.

Currently, as described by #66, if the last buffer in the last window is something you're filtering out (by default or with a custom buf_filter, when you restore that session you get an empty window. With this change, you'll instead get the most-recently-restored buffer from the session.

This should only affect single-window, single-tab scenarios (the existing behavior in those scenarios, where the window containing the filtered-out buffer is simply not restored) should be preserved by this change.

This isn't gated by an option because the current behavior felt like a bug to me, but it would be pretty easy to add a fall_back_to_most_recent option (maybe with a better name) if desired.

@github-actions github-actions bot requested a review from stevearc April 11, 2025 19:11
@stevearc
Copy link
Copy Markdown
Owner

stevearc commented Jun 1, 2025

Agree that this is better default behavior. Thanks for the PR!

@stevearc stevearc merged commit 84c81e5 into stevearc:master Jun 1, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants