Skip to content

Conversation

@AThePeanut4
Copy link
Contributor

This fixes an issue where restoring the custom sort order from a saved session doesn't work correctly most of the time, because it stores buffer ids in g:BufferlinePositions which are not preserved by :mksession. The fix is to store the full paths of the buffers instead. vim.json is required to stringify the list as :mksession only stores string/number values.

Split out from #777.

Copy link
Owner

@akinsho akinsho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AThePeanut4 this change looks good to me generally. Haven't had time to test it myself but would be great to have a test to just confirm that this logic works.

It could be something as simple as setup bufferline in a test (see bufferline_spec.lua then open 3 files e.g. vim.cmd.edit('example-1.txt') etc. Then run save_positions then run restore_positions and check that the state is what you expect

@AThePeanut4
Copy link
Contributor Author

Alright, I'll see what I can do.

@AThePeanut4
Copy link
Contributor Author

Alright I moved the functions to utils and added a test to utils_spec.lua. This PR doesn't really change anything outside of save|restore_positions so that's all I've tested.

@akinsho akinsho merged commit 2f391fd into akinsho:main Jun 28, 2023
@akinsho
Copy link
Owner

akinsho commented Jun 28, 2023

Merged, thanks for taking this on @AThePeanut4

@AThePeanut4 AThePeanut4 deleted the fix-persist-sort branch June 28, 2023 10:24
sstallion pushed a commit to sstallion/bufferline.nvim that referenced this pull request Jul 3, 2024
This fixes an issue where restoring the custom sort order from a saved session doesn't work correctly most of the time, because it stores buffer ids in g:BufferlinePositions which are not preserved by :mksession. The fix is to store the full paths of the buffers instead. vim.json is required to stringify the list as :mksession only stores string/number values.
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