Skip to content

fixed_input causes completion list to append recursively #119

@ColinKennedy

Description

@ColinKennedy
2024-12-06.12-46-02.mp4

When typing --foo=bar there's a chance that the whole string is included as part of the completion and it causes unexpected results. --foo=bar becomes --foo=bar--foo=bar.

As you continue typing, the entries are not cleared and it merges with the previous, causing hundreds of completions. (This is likely a separate issue related to should_merge_previous_items)

See the recording to show both issues at once

reproduction.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", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
      "neovim/nvim-lspconfig",
  },
  {
    "hrsh7th/nvim-cmp",
    config = function()
      local cmp = require("cmp")

      cmp.setup(
          {
              mapping = {
                  -- Moving through completions
                  ["<C-p>"] = cmp.mapping.select_prev_item(),
                  ["<C-n>"] = cmp.mapping.select_next_item(),
                  ['<C-y>'] = cmp.mapping.confirm { select = true },
              },
          }
      )

      cmp.setup.cmdline(":", {
          mapping = cmp.mapping.preset.cmdline(),
          sources = cmp.config.sources(
              {
                  { name = "path" },
              },
              {
                  {
                      name = "cmdline",
                      option = {
                          ignore_cmds = { "Man", "!" }
                      }
                  }
              }
          )
      })
    end,
    dependencies = {
      "hrsh7th/cmp-cmdline",
    }
  },
  {
    "ColinKennedy/nvim-best-practices-plugin-template",
    version = "v1.*",
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

Type :PluginTemplate hello-world say phrase --repeat= followed by some numbers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions