bufferline.nvim icon indicating copy to clipboard operation
bufferline.nvim copied to clipboard

[Bug]: Separator positions changes

Open yuttie opened this issue 3 years ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

What happened?

The positions of separators change when a user switch a tab.

In the following pictures, a customized highlight definitions are used to visually segment parts, and blue vertical lines are separators (specifically, the "thick" variant from presets). Brighter green (and bolder text) indicates that it is selected.

1st tab is selected: window_2022-07-17-155445

2nd tab is selected: window_2022-07-17-155448

3rd tab is selected: window_2022-07-17-155451

As you can see in the above pictures, separator positions changes by tab switching. In my opinion, this is a problem because it is non-intuitive and cannot be fixed by adjusting colorscheme.

The root cause of this is that the character used as the separator on the right side of the active tab is different from those of other tabs.

I think we may be able to fix this either by:

  • (a) Putting paired separator characters both sides of every tab as in the case of "slant" variation, or
  • (b) Using only a single separator character between tabs.

What did you expect to happen?

Separator positions never change by tab switching.

Config

require('bufferline').setup {
  options = {
    mode = 'tabs',
    themable = true,
    always_show_bufferline = true,
    separator_style = 'thick',
    left_mouse_command = vim.api.nvim_set_current_tabpage,
    middle_mouse_command = function(tabhandle)
      if table.getn(vim.api.nvim_list_tabpages()) > 1 then
        vim.cmd('tabclose ' .. vim.api.nvim_tabpage_get_number(tabhandle))
      end
    end,
    right_mouse_command = function(tabhandle)
      print(tabhandle, vim.api.nvim_tabpage_get_number(tabhandle))
    end,
    sort_by = function(buf_a, buf_b)
      -- print('------')
      -- for k, v in pairs(buf_a) do
      --   print(k, v)
      -- end
      -- print('------')
      if not buf_a and buf_b then
        return true
      elseif buf_a and not buf_b then
        return false
      end
      return buf_a.ordinal < buf_b.ordinal
      -- return vim.api.nvim_tabpage_get_number(buf_a.id) < vim.api.nvim_tabpage_get_number(buf_b.id)
    end,
  },
  highlights = function(config)
    local hl = {}

    for name, tbl in pairs(config.highlights) do
      local tbl_copy = {}
      for k, v in pairs(tbl) do
        -- Modify gui to remove italic
        if k == 'gui' then
          local parts = vim.split(v, ',')
          for _, part in pairs(parts) do
            if part ~= 'italic' then
              tbl_copy['gui'] = part
            end
          end
        else
          tbl_copy[k] = v
        end
      end
      hl[name] = tbl_copy
    end

    return hl
  end,
}

Additional Information

No response

commit

No response

yuttie avatar Jul 17 '22 07:07 yuttie

@yuttie so this dates all the way back to the inception of this plugin, and it's initial implementation. It's important to note that I did this intentionally, I can't remember all the reasons why, since the initial implementation was years ago now. At least one reason was aesthetic and allows a less buggy look when an active buffer is beside a visible buffer IIRC there might be a few more, but the crux of the issue is that this is this way on purpose as it was the best solution I found to a visual inconsistency I didn't like.

I really am not inclined to go changing this since this was as I recall the best solution to an otherwise intolerable visual issue I had, which for me makes the plugin unusable since I'm quite finicky and if it's not usable for me not worth maintaining.

You are able to change the separators yourself if they bother you, although, I'm not particularly following what aspect of this behaviour is causing an issue for you? This has never been raised as an issue before.

Also, if you wanted to attempt a PR to change this behaviour I could test that and see what comes up, I do think it's likely to throw up other issues but happy to revisit in a PR and see what those issues are, then at least I can document them for the future or see if there are other solutions

akinsho avatar Jul 17 '22 08:07 akinsho

@akinsho Thank you for the detailed explanation. I now understand that this is what was intended.

I don't know if I can find the time for PR, so for the time being I will try to change the separator to see if it can be made better.

Anyway, thank you for developing a great plugin!

yuttie avatar Jul 17 '22 11:07 yuttie

I think this can be fix by adding options to change indicator_icon for unselected buffer also. and options to change guibg for indicator wether selected/unselected/visible.

nikfple avatar Aug 08 '22 20:08 nikfple

I'm going to close this out having just revisited it today. I think as things stands they appear acceptable to me. If someone is interested in bringing this back up in the future please start with a PR that implements this change indicating what is different and how. ideally with screenshots as the OP here kindly did. As I mentioned at the top this was an old decision that I honestly don't have a problem with so would also be good for any PR to clearly point out why this is a problem for the user.

Sorry for what sounds like a laundry list of tasks but this isn't something that I'm going to action unless a bunch of people suddenly raise it as an issue and can explain why so if one or two people are bothered by it then then the onus will be on them to work to correct it and explain why that is needed 🙏🏾

akinsho avatar Apr 26 '23 18:04 akinsho