Skip to content

[BUG] The bufferline sometimes cannot work well with offsets #798

Closed

Description

@nullptr-yxw

When I open the neovim by directory, there is a line like this, even though I have set options.offset.test = "File Explorer"
image
And it will disappear when I move my cursor by mouse or keyboard

2023-08-02.13-31-15.mp4

Part of my settings is

offsets = {
    {
        filetype = "NvimTree",
        text = "File Explorer",
        highlight = "Directory",
        text_align = "left",
        separator = true,
    },
},
always_show_bufferline = true,

So is it possible to make the text of that line be "File Explorer", and do not disappear while moving the cursor?
Just like this(barbar.nvim)

2023-08-02.14-09-46.mp4

And there is another problem I have met which might be associated to this.
Sometimes when I close a buffer, the bufferline will not respect the offset

2023-08-02.14-20-47.mp4

Another bufferline plugin barbar.nvim doesn't have this problem as well

2023-08-02.14-23-09.mp4

Activity

  1. akinsho commented on Aug 2, 2023

    @akinsho
    Owner

    @nullptr-yxw please don't open multiple issues if they aren't very clearly indicated why each is different. I'm only one person maintaining this repo with lots of new issues all the time it just makes things harder. Please just detail precisely the problem on this one issue and if possible look at the code to consider helping raise a PR as well 🙏🏾

  2. nullptr-yxw commented on Aug 2, 2023

    @nullptr-yxw
    Author

    @nullptr-yxw please don't open multiple issues if they aren't very clearly indicated why each is different. I'm only one person maintaining this repo with lots of new issues all the time it just makes things harder. Please just detail precisely the problem on this one issue and if possible look at the code to consider helping raise a PR as well 🙏🏾

    @akinsho Ok, I have change this issue to describe the two problem in one issue

  3. akinsho commented on Aug 2, 2023

    @akinsho
    Owner

    @nullptr-yxw there is some confusion about this feature. Offsets are only relevant when there is more than one window open. When you open neovim in a directory and it is the only window open offsets do not apply, they never have that is not why they were designed.

    This can be added if you want to contribute it but is not the use case I designed them for.
    Regarding the naming of the offset that should work consistently and does for me but as I have mentioned offsets are not designed to apply when there is only one window open.

    When there is only one window open, there is no offset at all because nothing is being offset.
    Offsets are not a perfect solution without issue because offsets are a bit of a hack around native neovim behaviour. They do not cover all use cases and when I added the feature I explained that I was not going to sink hours of my time into fixing every edge case. The main use case for offsets is right or left aligned side bar that is open beside another window.

  4. nullptr-yxw commented on Aug 2, 2023

    @nullptr-yxw
    Author

    @nullptr-yxw there is some confusion about this feature. Offsets are only relevant when there is more than one window open. When you open neovim in a directory and it is the only window open offsets do not apply, they never have that is not why they were designed.

    This can be added if you want to contribute it but is not the use case I designed them for. Regarding the naming of the offset that should work consistently and does for me but as I have mentioned offsets are not designed to apply when there is only one window open.

    When there is only one window open, there is no offset at all because nothing is being offset. Offsets are not a perfect solution without issue because offsets are a bit of a hack around native neovim behaviour. They do not cover all use cases and when I added the feature I explained that I was not going to sink hours of my time into fixing every edge case. The main use case for offsets is right or left aligned side bar that is open beside another window.

    But what about the second problem? I only closed the main.cpp, and the functor.cpp still exists, but the behavior is not normal as well

  5. akinsho commented on Aug 2, 2023

    @akinsho
    Owner

    @nullptr-yxw the issue you are seeing is because bufferline uses the the native mechanism to close buffers in neovim :bdelete this command does not preserve your windows and is a well known and often discussed issue in the (n)vim ecosystem. There is a config option to replace that default command with some command of your own liking please read the README for how to configure the close action. Then use some plugin like nvim-bufdel or bufdelete.nvim etc. there are loads of options for that

  6. nullptr-yxw commented on Aug 2, 2023

    @nullptr-yxw
    Author

    @nullptr-yxw the issue you are seeing is because bufferline uses the the native mechanism to close buffers in neovim :bdelete this command does not preserve your windows and is a well known and often discussed issue in the (n)vim ecosystem. There is a config option to replace that default command with some command of your own liking please read the README for how to configure the close action. Then use some plugin like nvim-bufdel or bufdelete.nvim etc. there are loads of options for that

    Thanks for your answer and advice very much.

  7. akinsho commented on Aug 3, 2023

    @akinsho
    Owner

    The first issue might end up being fixed by #800 but in either case closing this out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions