stevearc / aerial.nvim

Neovim plugin for a code outline window
MIT License
1.68k stars 83 forks source link

bug: invalide buffer id when action.jump - on new AerialNav #242

Closed JoseConseco closed 1 year ago

JoseConseco commented 1 year ago

Neovim version (nvim -v)

NVIM v0.10.0-dev-107+g75d9c413d

Operating system/version

Arch linux

Output of :AerialInfo

Aerial Info

Aerial Info

Filetype: python Configured backends: treesitter (supported) (attached) lsp (supported) markdown (not supported) [Filetype is not markdown] Show symbols: Class, Constructor, Enum, Function, Interface, Method, Struct

Describe the bug

When I try to jump to selected item using new AerialNav I get this error:

E5108: Error executing lua: ...ocal/share/nvim/lazy/aerial.nvim/lua/aerial/nav_view.lua:309: Invalid buffer id: 334

stack traceback:
    [C]: in function 'nvim_buf_delete'
    ...ocal/share/nvim/lazy/aerial.nvim/lua/aerial/nav_view.lua:309: in function 'close'
    ...l/share/nvim/lazy/aerial.nvim/lua/aerial/nav_actions.lua:9: in function '_rhs'
    ...l/share/nvim/lazy/aerial.nvim/lua/aerial/keymap_util.lua:24: in function <...l/share/nvim/lazy/aerial.nvim/lua/aerial
/keymap_util.lua:23>

Can someone confirm this? Jumping into selected entry work ok in 'normal' Aerial. Only the nav version gives me this issue.

Steps To Reproduce

  1. Run AerialNavOpen
  2. try to jump to any selected entry ( using default [""] = "actions.jump", )
  3. I get error from 'description of bug'

Expected Behavior

It should jump to selected entry

Minimal example file

my config :

-- vim.api.nvim_set_keymap('n', '<F3>', ':AerialOpen float<CR> | :AerialTreeCloseAll<cr>', { noremap = true})

-- Call the setup function to change the default behavior
aerial = require "aerial"
require("aerial").setup {
  -- Priority list of preferred backends for aerial.
  -- This can be a filetype map (see :help aerial-filetype-map)
  backends = { "treesitter", "lsp", "markdown" },

  -- Enum: persist, close, auto, global
  --   persist - aerial window will stay open until closed
  --   close   - aerial window will close when original file is no longer visible
  --   auto    - aerial window will stay open as long as there is a visible
  --             buffer to attach to
  --   global  - same as 'persist', and will always show symbols for the current buffer
  -- close_behavior = "auto",
  close_automatic_events = { "unsupported" }, -- see :help aerial-close-behavior
  keymaps = {
    ["?"] = "actions.show_help",
    ["g?"] = "actions.show_help",
    ["<CR>"] = "actions.jump",
    -- ["<CR>"] = { callback = function() aerial.select(); aerial.close() end, desc = "", nowait = true },
    ["<2-LeftMouse>"] = "actions.jump",
    ["<C-v>"] = "actions.jump_vsplit",
    ["<C-s>"] = "actions.jump_split",
    ["p"] = "actions.scroll",
    ["<C-j>"] = "actions.down_and_scroll",
    ["<C-k>"] = "actions.up_and_scroll",
    ["{"] = "actions.prev",
    ["}"] = "actions.next",
    ["[["] = "actions.prev_up",
    ["]]"] = "actions.next_up",
    ["q"] = "actions.close",
    ["o"] = "actions.tree_toggle",
    ["za"] = "actions.tree_toggle",
    ["O"] = "actions.tree_toggle_recursive",
    ["zA"] = "actions.tree_toggle_recursive",
    -- ["l"] = "actions.tree_open",
    ["l"] = {
      callback = function()
        local current_line_str = vim.api.nvim_get_current_line()
        aerial.tree_close_all()
        vim.fn.search(current_line_str)
        aerial.tree_open()
      end,
      desc = "",
      nowait = true,
    },
    ["zo"] = "actions.tree_open",
    ["L"] = "actions.tree_open_recursive",
    ["zO"] = "actions.tree_open_recursive",
    ["h"] = "actions.tree_close",
    ["zc"] = "actions.tree_close",
    ["H"] = "actions.tree_close_recursive",
    ["zC"] = "actions.tree_close_recursive",
    ["zr"] = "actions.tree_increase_fold_level",
    ["zR"] = "actions.tree_open_all",
    ["zm"] = "actions.tree_decrease_fold_level",
    ["zM"] = "actions.tree_close_all",
    ["zx"] = "actions.tree_sync_folds",
    ["zX"] = "actions.tree_sync_folds",
  },
  nav = {
    preview = true,
    keymaps = {
      ["<CR>"] = "actions.jump",
      ["<Esc>"] = "actions.close",
      q = "actions.close",
    },
  },

  -- Disable aerial on files with this many lines
  disable_max_lines = 10000,

  -- Enum: split_width, full_width, last, none
  -- Determines line highlighting mode when multiple splits are visible.
  -- split_width   Each open window will have its cursor location marked in the
  --               aerial buffer. Each line will only be partially highlighted
  --               to indicate which window is at that location.
  -- full_width    Each open window will have its cursor location marked as a
  --               full-width highlight in the aerial buffer.
  -- last          Only the most-recently focused window will have its location
  --               marked in the aerial buffer.
  -- none          Do not show the cursor locations in the aerial window.
  highlight_mode = "split_width",

  -- Highlight the closest symbol if the cursor is not exactly on one.
  highlight_closest = true,

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

  -- Define symbol icons. You can also specify "<Symbol>Collapsed" to change the
  -- icon when the tree is collapsed at that symbol, or "Collapsed" to specify a
  -- default collapsed icon. The default icon set is determined by the
  -- "nerd_font" option below.
  -- If you have lspkind-nvim installed, aerial will use it for icons.
  -- icons = {},

  -- Control which windows and buffers aerial should ignore.
  -- If close_behavior is "global", focusing an ignored window/buffer will
  -- not cause the aerial window to update.
  -- If open_automatic is true, focusing an ignored window/buffer will not
  -- cause an aerial window to open.
  -- If open_automatic is a function, ignore rules have no effect on aerial
  -- window opening behavior; it's entirely handled by the open_automatic
  -- function.

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

  -- These control the width of the aerial window.
  -- They can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
  -- min_width and max_width can be a list of mixed types.
  -- max_value = {40, 0.2} means "the lesser of 40 columns or 20% of total"
  layout = {
    max_width = { 80, 0.5 },
    width = nil,
    min_width = 20,
    -- Enum: prefer_right, prefer_left, right, left, float
    -- Determines the default direction to open the aerial window. The 'prefer'
    -- options will open the window in the other direction *if* there is a
    -- different buffer in the way of the preferred direction
    default_direction = "prefer_right",
  },

  -- 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 = false,

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

  -- A list of all symbols to display. Set to false to display all symbols.
  -- This can be a filetype map (see :help aerial-filetype-map)
  -- To see all available values, see :help SymbolKind
  filter_kind = {
    "Class",
    "Constructor",
    "Enum",
    "Function",
    "Interface",
    "Method",
    "Struct",
  },

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

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

  -- The autocmds that trigger symbols update (not used for LSP backend)
  update_events = "TextChanged,InsertLeave",

  -- Customize the characters used when show_guides = true
  guides = {
    -- When the child item has a sibling below it
    mid_item = "├─",
    -- When the child item is the last in the list
    last_item = "└─",
    -- When there are nested child guides to the right
    nested_top = "│ ",
    -- Raw indentation
    whitespace = "  ",
  },

  -- Options for opening aerial in a floating win
  float = {
    -- Controls border appearance. Passed to nvim_open_win
    border = "rounded",
    -- Enum: cursor, editor, win
    --   cursor - Opens float on top of the cursor
    --   editor - Opens float centered in the editor
    --   win    - Opens float centered in the window
    relative = "cursor",
    -- These control the height of the floating window.
    -- They can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
    -- min_height and max_height can be a list of mixed types.
    -- min_value = {8, 0.1} means "the greater of 8 rows or 10% of total"
    max_height = 0.9,
    height = nil,
    min_height = { 8, 0.1 },
    override = function(conf)
      -- This is the config that will be passed to nvim_open_win.
      -- Change values here to customize the layout
      return conf
    end,
  },

  lsp = {
    -- Fetch document symbols when LSP diagnostics update.
    -- If false, will update on buffer changes.
    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,
  },
}

Minimal init.lua

Nope

Additional context

Nope

stevearc commented 1 year ago

Not sure how that buffer could be getting deleted early, but I've silenced the error