noice.nvim icon indicating copy to clipboard operation
noice.nvim copied to clipboard

bug: certain notifications ignore `merge = false` and `replace = false`

Open chrisgrieser opened this issue 11 months ago • 0 comments

Did you check docs and existing issues?

  • [X] I have read all the noice.nvim docs
  • [X] I have searched the existing issues of noice.nvim
  • [X] I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

neovim 0.9.1 (homebrew)

Operating system/version

macOS 13.4.1 (M1)

Describe the bug

It's essentially what I described here, which after further investigation, I believe to be a bug. Essentially, print() seems to ignore merge = false and replace = false, while vim.notify does not. As far as I can tell, both use the same view though.

This quite inconvenient, since I use a lot print for debugging, and some print messages being "swallowed" can be very misleading (actually lost a good 2 hours to figure out the bug was not in my code, but in the fact that multiple prints just got swallowed 🙈 )

vim.keymap.set("n", ",q", function()
	print("foo")
	print("bar")
end)

vim.keymap.set("n", ",Q", function()
	vim.notify("foo")
	vim.notify("bar")
end)

output of two times print (,q) Pasted image 2023-07-31 at 14 21 13@2x

output of two times vim.notify (,Q) Pasted image 2023-07-31 at 14 21 27@2x


The default view config already sets both, replace and merge, to false.

Steps To Reproduce

  1. Run repo code below
  2. run ,q for 2x print()
  3. run,Q for 2x vim notify

Expected Behavior

  • print output should respect merge = false and replace = false
  • print and vim.notify should behave consistently, since they both use the same view

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 with minimal LSP setup
local plugins = {
	"folke/tokyonight.nvim",
	{
		"folke/noice.nvim",
		dependencies = { "MunifTanjim/nui.nvim", "rcarriga/nvim-notify" },
		opts = true,
	},
}

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

vim.cmd.colorscheme("tokyonight")

---------------------------------------------------------------------

vim.keymap.set("n", ",q", function()
	print("foo")
	print("bar")
end)

vim.keymap.set("n", ",Q", function()
	vim.notify("foo")
	vim.notify("bar")
end)

chrisgrieser avatar Jul 31 '23 13:07 chrisgrieser