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] Failed to rename buffer #89

Closed
ten3roberts opened this issue Apr 25, 2022 · 2 comments
Closed

[Bug] Failed to rename buffer #89

ten3roberts opened this issue Apr 25, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ten3roberts
Copy link
Contributor

Describe the bug
Failed to rename buffer when switching between buffers, e.g; .

System information

  • OS: Linux
  • Neovim version: 0.8.0+53
  • AerialInfo:
Aerial Info
-----------
Filetype: rust
Configured backends:
  lsp (supported) (attached)
  treesitter (supported)
  markdown (not supported) [Filetype is not markdown]
Show symbols: Class, Constructor, Enum, Function, Interface, Module, Method, Struct

  • Aerial config:
-- Call the setup function to change the default behavior
require("aerial").setup({
  backends = { "lsp", "treesitter", "markdown" },

  close_behavior = "global",

  default_bindings = true,
  default_direction = "prefer_left",

  disable_max_lines = 10000,

  highlight_mode = "split_width",

  -- When jumping to a symbol, highlight the line for this many ms.
  -- Set to false to disable
  highlight_on_jump = 300,

  -- When you fold code with za, zo, or zc, update the aerial tree as well.
  -- Only works when manage_folds = true
  link_folds_to_tree = false,

  -- Fold code when you open/collapse symbols in the tree.
  -- Only works when manage_folds = true
  link_tree_to_folds = true,

  -- Use symbol tree for folding. Set to true or false to enable/disable
  -- 'auto' will manage folds if your previous foldmethod was 'manual'
  manage_folds = false,

  -- The maximum width of the aerial window
  max_width = { 20, 0.2 },

  -- The minimum width of the aerial window.
  -- To disable dynamic resizing, set this to be equal to max_width

  -- Set default symbol icons to use patched font icons (see https://www.nerdfonts.com/)
  -- "auto" will set it to true if nvim-web-devicons or lspkind-nvim is installed.
  nerd_font = "auto",

  -- Call this function when aerial attaches to a buffer.
  -- Useful for setting keymaps. Takes a single `bufnr` argument.
  on_attach = nil,

  -- Automatically open aerial when entering supported buffers.
  -- This can be a function (see :help aerial-open-automatic)
  open_automatic = true,

  -- Set to true to only open aerial at the far right/left of the editor
  -- Default behavior opens aerial relative to current window
  placement_editor_edge = true,

  -- Run this command after jumping to a symbol (false will disable)
  post_jump_cmd = "normal! zz",

  -- When true, aerial will automatically close after jumping to a symbol
  close_on_select = false,

  -- Show box drawing characters for the tree hierarchy
  show_guides = false,

  lsp = {
    -- Fetch document symbols when LSP diagnostics change.
    -- If you set this to false, you will need to manually fetch symbols
    diagnostics_trigger_update = true,

    -- Set to false to not update the symbols when there are LSP errors
    update_when_errors = true,
  },

  treesitter = {
    -- How long to wait (in ms) after a buffer change before updating
    update_delay = 300,
  },

  markdown = {
    -- How long to wait (in ms) after a buffer change before updating
    update_delay = 300,
  },

})

To Reproduce
Steps to reproduce the behavior:

  1. Open a file and let Aerial open
  2. Switch to any other file (Telescope, etc)

Screenshots
Screenshot from 2022-04-25 22-02-15

Additional context
Appears after 4dc2193

The bug appears to resolve if your plugin stickybuf is disabled.

I have not been able to reproduce the error using the lua api.

api.nvim_buf_set_name(-1|4023,nil, "") -> Invalid buffer id
api.nvim_buf_set_name(0, nil) -> Expected lua string

The only way that error message can occur is if nvim is aborting, or the more likely, the buffer is changed during renaming, which I guess is due to a stickybuf autocommand firing right when displaying the new buffer symbols right at switching time.

Neovim source responsible for the error message:

https://github.com/neovim/neovim/blob/af82eab946cf9f36e544b0591b8c8c02e8ddf316/src/nvim/api/buffer.c#L1102-L1126

https://github.com/neovim/neovim/blob/af82eab946cf9f36e544b0591b8c8c02e8ddf316/src/nvim/ex_cmds.c#L1704-L1711

@ten3roberts ten3roberts added the bug Something isn't working label Apr 25, 2022
stevearc added a commit that referenced this issue Apr 25, 2022
@stevearc
Copy link
Owner

Caused by #87. Happens because buffer names must be unique, but more than one Aerial buffer can exist at a time. I have reverted the change

@ten3roberts
Copy link
Contributor Author

That fixed it. Now I know that buffer names must be unique, which makes sense, can't really open the same file twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants