Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First yanked element is displayed twice on Telescope picker #26

Open
becarepsol opened this issue Oct 6, 2021 · 3 comments
Open

First yanked element is displayed twice on Telescope picker #26

becarepsol opened this issue Oct 6, 2021 · 3 comments

Comments

@becarepsol
Copy link

When using Telescope to pick yank registers the first element that I yanked is
displayed twice, as if I had yanked twice.

Subsequent yanked elements behave correctly, meaning that they don't get
duplicated

This is my current config:

	use({
		"AckslD/nvim-neoclip.lua",
		event = "TextYankPost",
		config = function()
			require("neoclip").setup({
				enable_persistant_history = true,
				keys = {
					i = {
						paste = "<c-y>",
						paste_behind = "<c-b>",
					},
				},
			})
		end,
		requires = {
			"tami5/sqlite.lua",
			module = "sqlite",
		},
	})

neoclip

Thanks

@AckslD
Copy link
Owner

AckslD commented Oct 6, 2021

Hi @becarepsol! Thanks for reporting this.

It does not happen for me, do you perhaps have some local config interacting with TextYankPost?

Would you mind for example adding a print statement here to see if for some reason the handler of the yank is called twice or if there is another issue?

Edit: Does is also happen btw if you remove event = 'TextYankPost' in the packer config?

@becarepsol
Copy link
Author

Hi @AckslD Thanks for the reply,

The only other config that interacts with TextYankPost is this helper
function to easily define autogroups

local funcs = {}

function funcs.define_augroups(definitions)
	for group_name, definition in pairs(definitions) do
		vim.cmd("augroup " .. group_name)
		vim.cmd("autocmd!")

		for _, def in pairs(definition) do
			local command = table.concat(vim.tbl_flatten({ "autocmd", def }), " ")
			vim.cmd(command)
		end

		vim.cmd("augroup END")
	end
end

return funcs

That then gets call to setup vim.highlight.on_yank()

local func = require("utils.augroup")

func.define_augroups({
	_general_settings = {
		{ "TextYankPost", "*", "lua require('vim.highlight').on_yank({higroup = 'YankHighlight', timeout = 200})" },
	},
})

And yes, after removing event = 'TextYankPost' in the packer config it
works as expected, no first yank duplication

Finally I just want to further clarify that this unexpected behavior only
happens with the first yanked element after freshly starting vim, and further
yanks are added only once to the clipboard as expected

Thanks

@AckslD
Copy link
Owner

AckslD commented Oct 6, 2021

@becarepsol This seems to be a bug in packer which I could reproduce, I opened a small PR wbthomason/packer.nvim#636 which I think should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants