Skip to content

Misc bugs with builtin.registers #3462

@mathiasuk

Description

@mathiasuk

Description

I've been using builtin.registers and have the notice the following few bugs:

  1. Editing read-only registers content results in an error

  2. Editing named registers content appends instead of edit.

  3. Picker not updated when editing a registers value.

Neovim version

NVIM v0.11.0
Build type: Release
LuaJIT 2.1.1741730670

Operating system and version

Debian Testing

Telescope version / branch / rev

telescope / master / latest

checkhealth telescope

==============================================================================
telescope:                                              health#telescope#check

Checking for required plugins
- OK plenary installed.
- OK nvim-treesitter installed.

Checking external dependencies
- OK rg: found ripgrep 14.1.1
- OK fd: found fdfind 10.2.0

===== Installed extensions =====

Steps to reproduce

    1. Save data to a register, e.g.: "ayy
    2. :Telescope registers
    3. Select a read-only register (e.g.: ".", "%" or ":")
    4. to edit the register, enter new value,

2-3.

  1. Save data to a register, e.g.: "ayy
  2. :Telescope registers
  3. Select the register (e.g. "a")
  4. to edit the register, enter new value,

Expected behavior

  1. Attempting to edit read-only registers should be ignored
  2. Editing named registers should use the lowercase letters to replace instead of append
  3. Picker should be refreshed after editing a register

Actual behavior

  1. Editing read-only registers content results in an error

Three registers are read-only ":, ". and "% which result in the following error if one attempts to edit them:

Edit [:] ❯ Telescope registersaE5108: Error executing lua: Vim:E354: Invalid register name: ':'
stack traceback:
        [C]: in function 'setreg'
        .../nvim/lazy/telescope.nvim/lua/telescope/actions/init.lua:454: in function 'run_replace_or_original'
        ...re/nvim/lazy/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
        ...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:293: in function <...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:292>
  1. Editing named registers content appends instead of edit.

Editing any of the named registers (a-z) is one with the uppercase letter (A-Z) which results in the edited content to be added to the existing content. This is due to the default behaviour of using the uppercase version of the letter when setting the register value (see :h quote_alpha)

  1. Picker not updated when editing a registers value.

After editing a register value the picker is not updated and shows the old value until the picker is closed and open again.

Minimal config

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.uv.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 = {
  {
    "nvim-telescope/telescope.nvim",
    dependencies = {
      "nvim-lua/plenary.nvim",
    },
    config = function()
      -- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
      require("telescope").setup {}
    end,
  },
}

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions