stevearc / aerial.nvim

Neovim plugin for a code outline window
MIT License
1.55k stars 76 forks source link

bug: telescope aerial stays at mid #346

Closed yimingwangdell closed 2 weeks ago

yimingwangdell commented 4 months ago

Neovim version (nvim -v)

latest

Operating system/version

debian

Output of :AerialInfo

xx

Describe the bug

telescope aerial cursor starts at mid.

What is the severity of this bug?

minor (annoyance)

Steps To Reproduce

any

Expected Behavior

telescope aerial cursor stays at bottom and select the correct item.

Minimal example file

No response

Minimal init.lua

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    "stevearc/aerial.nvim",
    config = function()
      require("aerial").setup({
        -- add your aerial config here
      })
    end,
  },
  {
    "nvim-treesitter/nvim-treesitter",
    build = ":TSUpdate",
    config = function()
      require("nvim-treesitter.configs").setup({
        ensure_installed = { "c", "lua" },
        auto_install = true,
        highlight = { enable = true },
      })
    end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Additional context

No response

yimingwangdell commented 4 months ago

after researching, I found that when running "Telescope aerial", the cursor by default starts on the nth item related to nth function your cursor located. it should be starting on last(bottom) item. because last item is most matched item.

yimingwangdell commented 4 months ago

@stevearc

stevearc commented 3 weeks ago

The cursor starts on the current symbol, and the symbols are ordered the same way they are in the file. Once you start typing and the number of results changes, the cursor jumps to the last item. This all seems correct to me.

Is your request to have the cursor start on the last symbol in the file, regardless of where your current cursor position is?

yimingwangdell commented 3 weeks ago

@stevearc sometime it didn't work. if I type only one character, there is no preselected item at bottom. then if I type \<up> to preselect one item, it was not the last one.

stevearc commented 2 weeks ago

I think that what is happening is that telescope only moves the cursor to the bottom after the total number of results displayed has changed. If you type a single character that doesn't filter out any of the results, the cursor will stay somewhere in the midpoint. Is this the behavior you are seeing? This is arguably a bug in telescope since that is probably not intentional behavior, but it also is generally not an issue in practice since typing two characters is usually enough to filter out at least one result.