folke / which-key.nvim

💥 Create key bindings that stick. WhichKey helps you remember your Neovim keymaps, by showing available keybindings in a popup as you type.
Apache License 2.0
5.38k stars 177 forks source link

bug: Interferes with system clipboard #518

Closed 9mm closed 3 months ago

9mm commented 1 year ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.9.2

Operating system/version

OSX 13.5.2 (22G91)

Describe the bug

This took me awhile to isolate this down to which-key, however when the plugin is disabled the problem disappears, and re-appears when plugin is enabled again.

The problem is... if you delete into system clipboard, and immediately delete into vim clipboard/buffer, and then paste out of system clipboard... it will paste the buffer output instead of system output. See below for reproduction steps.

I don't have much plugin configuration... this is it:

return {
  'folke/which-key.nvim',
  event = 'VeryLazy',
  config = function()
    require('which-key').setup()
  end,
}

Steps To Reproduce

Put the following in a file:

apple
banana
cherry

Press <S-v> and highlight apple.

Press "+d to delete into system clipboard.

Now immediately (without pressing movement or other keys) press dd to delete a line into standard buffer

Now... press "+p to put whats in the system clipboard. It will be the wrong text... what you just deleted with dd.


Now, do this again, but instead of pressing dd... press j or k to move around, now go BACK to the same line, press dd (so basically instead of deleting right away, move around, THEN delete)

Now when you press "+p it will have the CORRECT output

Expected Behavior

The standard vim buffer should never interfere with the + system buffer

The following "repro" below illustrates the issue

Repro

-- 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 = {
  "folke/tokyonight.nvim",
  { "folke/which-key.nvim", config = true },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
github-actions[bot] commented 4 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

9mm commented 4 months ago

this definitely still happens, and is definitely extremely annoying still

9mm commented 3 months ago

absolutely based