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
Preserve buffer order when loading session #9520
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## master #9520 +/- ##
==========================================
+ Coverage 82.62% 83.15% +0.53%
==========================================
Files 154 154
Lines 171015 174164 +3149
Branches 39178 39181 +3
==========================================
+ Hits 141294 144830 +3536
- Misses 16669 17216 +547
+ Partials 13052 12118 -934
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
echasnovski
added a commit
to echasnovski/neovim
that referenced
this pull request
Jan 16, 2022
…te different Problem: After restoring a session buffer order can be quite different. Solution: Create buffers first. (Evgeni Chasnovski, closes vim/vim#9520) vim/vim@26ebf1f --------------- Also update functional test about restoring same terminals. It was a bit too restrictive with using actual buffer ids, which changed with this patch (now they should be in the same order as at `mksession` call).
echasnovski
added a commit
to echasnovski/neovim
that referenced
this pull request
Jan 16, 2022
…te different Problem: After restoring a session buffer order can be quite different. Solution: Create buffers first. (Evgeni Chasnovski, closes vim/vim#9520) vim/vim@26ebf1f --------------- As in Vim, this basically reverts 8.1.0829 providing different solution (see vim/vim#9520). Regarding Neovim, this basically reverts changes from neovim#15062. Test about restoring same terminals was a bit too restrictive with using actual buffer ids, which changed with this patch (now they should be in the same order as at `mksession` call), so I tweaked it.
seandewar
pushed a commit
to neovim/neovim
that referenced
this pull request
Jan 29, 2022
…te different (#17112) Problem: After restoring a session buffer order can be quite different. Solution: Create buffers first. (Evgeni Chasnovski, closes vim/vim#9520) vim/vim@26ebf1f --------------- As in Vim, this basically reverts 8.1.0829 providing different solution (see vim/vim#9520). Regarding Neovim, this basically reverts changes from #15062. Test about restoring same terminals was a bit too restrictive with using actual buffer ids, which changed with this patch (now they should be in the same order as at `mksession` call), so I tweaked it.
dmitmel
pushed a commit
to dmitmel/neovim
that referenced
this pull request
Apr 16, 2022
…te different (neovim#17112) Problem: After restoring a session buffer order can be quite different. Solution: Create buffers first. (Evgeni Chasnovski, closes vim/vim#9520) vim/vim@26ebf1f --------------- As in Vim, this basically reverts 8.1.0829 providing different solution (see vim/vim#9520). Regarding Neovim, this basically reverts changes from neovim#15062. Test about restoring same terminals was a bit too restrictive with using actual buffer ids, which changed with this patch (now they should be in the same order as at `mksession` call), so I tweaked it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a PR to fix #4352. It basically reverts 8.1.0829 and fixes its problem differently.
Current behavior is that all visible buffers along with alternative file are loaded first and then the rest ones. This happens because
badd
commands in session file are sourced near the end, afteredit
andbalt
commands. Placingbadd
commands near the end was a fix for extra empty buffers created whenhidden
was on and there were several tab pages to be restored.After some investigation, the main reason for empty buffers seems to be plain
tabnew
calls in the beginning of session file to restore tabs (which in itself is a fix introduced in #3152, patch 8.1.0149). As a result oftabnew
, each tab is created with new empty buffer. After later calls oftabnext
andedit <file>
these buffers disappear unless<file>
is already loaded in another buffer.My proposed fix is to open placeholder tab with empty buffer intentionally set to be wiped out after it is no longer needed. This change doesn't break any existing tests. The only situation I can think of where this local setting might matter is when user intentionally created session for tab with empty buffer. In that case its local
bufhidden
will be restored in later options restoration (if "options" is present insessionoptions
, meaning user cares about those options at all).What I also tried
nohidden
and restoring. Resulted into placeholder empty buffers becoming unlisted but not completely absent.tabnew
calls in favor oftabedit
calls later instead ofedit
, but it basically reverted Fix mksession to set localdir correctly when there are multiple tabs #3152 and brokeTest_mksession_lcd_multiple_tabs()
test.Additional justification
In original issue it is stated that there is no clearly documented guarantee of preserving buffer order, which is true. Also it might seem like a minor thing and cosmetic change. However, besides use case from this comment (relying on manual buffer order in workflow), it becomes more visible when using tabline to show buffers instead of tabs, which seems to be quite common practise. In that case ever changing order is pretty inconvenient.