Skip to content
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

Bug: The plugin cannot work well with ctrl-o #28

Closed
nullptr-yxw opened this issue Feb 1, 2024 · 3 comments
Closed

Bug: The plugin cannot work well with ctrl-o #28

nullptr-yxw opened this issue Feb 1, 2024 · 3 comments

Comments

@nullptr-yxw
Copy link

nullptr-yxw commented Feb 1, 2024

When using ctrl-o to go to an older cursor position, the current window might change to other buffer if the current buffer doesn't have enough items in the jump list. And if the current buffer is locked by stickybuf.nvim, it will vertically split the window.

Press ctrl-o several times:(the help buffer has been locked by stickybuf.nvim).

nvim.2024-02-01.22-01-38.mp4
@stevearc
Copy link
Owner

Interesting, the default pinning for help buffers should allow them to be replaced by other help buffers. When I try to repro this (by doing :help then :help autocmd), the jumping works fine until I go back to a non-help file. Can you produce a minimal repro config that exhibits this behavior?

@stevearc stevearc added the question Further information is requested label Feb 20, 2024
@nullptr-yxw
Copy link
Author

@stevearc I mean that if I go back to a non-help file, it will vertically split the window.

@github-actions github-actions bot removed the question Further information is requested label Feb 28, 2024
@stevearc
Copy link
Owner

There is no way for stickybuf to tell the difference between switching buffers via :edit, or a file picker, or <C-o>. If this bothers you, you could set the handle_foreign_buffer function to no-op or display a warning instead of opening the new buffer in a vertical split. Example:

require("stickybuf").setup({
  get_auto_pin = function(bufnr)
    local pin_type = require("stickybuf").should_auto_pin(bufnr)
    if pin_type then
      return {
        allow_type = pin_type,
        handle_foreign_buffer = function()
          vim.notify("Cannot open buffer in pinned window", vim.log.levels.WARN)
        end,
      }
    end
  end,
})

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

No branches or pull requests

2 participants