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

Bug: The plugin cannot work well with ctrl-o

Open nullptr-yxw opened this issue 1 year ago • 2 comments

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).

https://github.com/stevearc/stickybuf.nvim/assets/96286337/074407cf-f749-4d0c-9733-d0c921685856

nullptr-yxw avatar Feb 01 '24 14:02 nullptr-yxw

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 avatar Feb 20 '24 07:02 stevearc

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

nullptr-yxw avatar Feb 28 '24 03:02 nullptr-yxw

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,
})

stevearc avatar May 14 '24 03:05 stevearc