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

bug: cmdline.view overwrites cmdline.format.search_down.view ~50% of the time. #841

Closed
3 tasks done
chrisgrieser opened this issue Jun 7, 2024 · 5 comments · Fixed by #843
Closed
3 tasks done
Labels
bug Something isn't working

Comments

@chrisgrieser
Copy link

chrisgrieser commented Jun 7, 2024

Did you check docs and existing issues?

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

Neovim version (nvim -v)

NVIM v0.10.0

Operating system/version

macOS 14.4.1 (arm)

Describe the bug

So this is a weird one.

This config results in the / search sometimes using the cmdline, and sometimes using the cmdline_popup. Happens about every other time.

cmdline = {
	view = "cmdline_popup",
	format = {
		search_down = { view = "cmdline" },
	},
},

And with this config, the search always uses the cmdline.

cmdline = {
	view = "cmdline",
	format = {
		search_down = { view = "cmdline" },
	},
},

My assumption is that cmdline.view apparently overwrites cmdline.format.search_down.view based on a certain race condition?
Also, the problem does not seem to occur for cmdline.format.cmdline.view and the others. (Though I haven't tried every possible permutation).

Steps To Reproduce

  1. Use the config
  2. restart nvim
  3. press /

Repeat 2. and 3. multiple times; the view used is not consistent.

Showcase

Expected Behavior

The cmdline.format.search_down.view setting should work, consistently.

Repro

local plugins = {
	{
		"folke/noice.nvim",
		dependencies = "MunifTanjim/nui.nvim",
		opts = {
			cmdline = {
				view = "cmdline_popup",
				format = {
					search_down = { view = "cmdline" },
				},
			},
			-- cmdline = {
			-- 	view = "cmdline",
			-- 	format = {
			-- 		search_down = { view = "cmdline" },
			-- 	},
			-- },
		},
	},
}

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

for _, name in ipairs { "config", "data", "state", "cache" } do
	vim.env[("XDG_%s_HOME"):format(name:upper())] = "/tmp/nvim-debug/" .. name
end

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if vim.uv.fs_stat(lazypath) == nil then
	local lazyrepo = "https://github.com/folke/lazy.nvim"
	vim.system({ "git", "clone", "--filter=blob:none", lazyrepo, "--branch=stable", lazypath }):wait()
end
vim.opt.runtimepath:prepend(lazypath)
require("lazy").setup(plugins)
@chrisgrieser chrisgrieser added the bug Something isn't working label Jun 7, 2024
@b0ae989c
Copy link
Contributor

b0ae989c commented Jun 7, 2024

Yes I can confirm this issue also appears on macOS 14.5 with NVIM v0.10.0 (LuaJIT 2.1.1716656478).

@b0ae989c
Copy link
Contributor

b0ae989c commented Jun 7, 2024

Is this related to the change of vim.deepcopy (merged since v0.10.0) in neovim/neovim@3734519 ? Since it's in cmdline setup

}, { opts = vim.deepcopy(Config.options.cmdline.opts) }, format)

@folke
Copy link
Owner

folke commented Jun 7, 2024

Might be!

Would be great f you could check it's fixed with passing noref = true and make a PR if that fixes it.

b0ae989c added a commit to b0ae989c/noice.nvim that referenced this issue Jun 7, 2024
b0ae989c added a commit to b0ae989c/noice.nvim that referenced this issue Jun 7, 2024
b0ae989c added a commit to b0ae989c/noice.nvim that referenced this issue Jun 7, 2024
@folke
Copy link
Owner

folke commented Jun 7, 2024

I found the issue. It only happens for search.
Add search_up to fix it.

        format = {
          search_down = {
            view = "cmdline",
          },
          search_up = {
            view = "cmdline",
          },
        },

Reason is that for search, the message kind is for both just search, so the cmdline will basically switch between two at random.

Will see to make a proper fix

@chrisgrieser
Copy link
Author

works fine now, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants