diff --git a/README.md b/README.md index 1d5c2e8f..bc3ef6e2 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,6 @@ it has a lot of the same features/styling but not all. A few things to note are -- Diagnostics only show if the buffer with issues is the current window selected in that tab page - Sorting doesn't work yet as that needs to be thought through. - Grouping doesn't work yet as that also needs to be thought through. diff --git a/doc/bufferline.txt b/doc/bufferline.txt index 9bf68122..909e5c29 100644 --- a/doc/bufferline.txt +++ b/doc/bufferline.txt @@ -197,8 +197,6 @@ This plugin can also be set to show only tabpages. This can be done by setting the `mode` option to `tabs`. This will change the bufferline to a tabline it has a lot of the same features/styling but not all. A few things to note are -* Diagnostics only show if the buffer with issues is the current window selected - in that tab page. * Sorting doesn't work yet as that needs to be thought through. * Grouping doesn't work yet as that also needs to be thought through. @@ -1073,7 +1071,7 @@ WORKING WITH ELEMENTS *bufferline-working-with-elements* Bufferline exposes some information about the buffers it shows will allow you to implement your own custom functionality. Note that this will not include any -buffers that are filtered out of bufferline, making it handy for writing +buffers that are filtered out of bufferline, making it handy for writing functions that need to ignore special buffers. The output has the following structure: diff --git a/lua/bufferline/config.lua b/lua/bufferline/config.lua index eae99f81..45aa1d19 100644 --- a/lua/bufferline/config.lua +++ b/lua/bufferline/config.lua @@ -779,10 +779,7 @@ function Config:resolve(defaults) if self:is_tabline() then local opts = defaults.options - -- If the sort by mechanism is "tabs" but the user is in tabline mode - -- then the id will be that of the tabs so sort by should be id i.e. "tabs" sort - -- is redundant in tabs mode - if opts.sort_by == "tabs" then opts.sort_by = "id" end + opts.sort_by = "tabs" if opts.show_tab_indicators then opts.show_tab_indicators = false end opts.close_command = utils.close_tab opts.right_mouse_command = "tabclose %d" diff --git a/lua/bufferline/sorters.lua b/lua/bufferline/sorters.lua index ca347fc3..f1f82cfd 100644 --- a/lua/bufferline/sorters.lua +++ b/lua/bufferline/sorters.lua @@ -57,6 +57,12 @@ end --- @param buf_a NvimBuffer --- @param buf_b NvimBuffer +local function sort_by_tabpage_number(buf_a, buf_b) + local a = vim.api.nvim_tabpage_get_number(buf_a.id) + local b = vim.api.nvim_tabpage_get_number(buf_b.id) + return a < b +end + local function sort_by_tabs(buf_a, buf_b) local buf_a_tabnr = init_buffer_tabnr(buf_a) local buf_b_tabnr = init_buffer_tabnr(buf_b) @@ -139,7 +145,7 @@ function M.sort(elements, sort_by, state) elseif sort_by == "id" then table.sort(elements, sort_by_id) elseif sort_by == "tabs" then - table.sort(elements, config:is_tabline() and sort_by_id or sort_by_tabs) + table.sort(elements, config:is_tabline() and sort_by_tabpage_number or sort_by_tabs) elseif type(sort_by) == "function" then table.sort(elements, sort_by) end