folke / noice.nvim

💥 Highly experimental plugin that completely replaces the UI for messages, cmdline and the popupmenu.
Apache License 2.0
4.32k stars 100 forks source link

bug: Cursor jumps in cmdline - 4.5.0 (MacOS + Wezterm) #950

Closed gotgenes closed 3 weeks ago

gotgenes commented 3 weeks ago

Did you check docs and existing issues?

Neovim version (nvim -v)

v0.10.1 Release

Operating system/version

MacOS 14.6.1

Describe the bug

Opening a new issue per this comment in #923.

Steps To Reproduce

  1. Install Noice with minimal repro setup shown below.
  2. Open Wezterm
  3. Start Neovim
  4. Open the command :
  5. Observe the cursor flickering between the command prompt and another part of the Neovim UI.

Expected Behavior

The cursor stays rendered in the command prompt, and does not flicker around.

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    { "folke/noice.nvim", opts = {} },
    -- add any other plugins here
  },
})
folke commented 3 weeks ago

Install Noice with LazyVim

I need a proper repro. Not a LAzyVim install.

Does the issue trigger with the provided repro?

folke commented 3 weeks ago

And like I said, please use a recent nightly to reproduce.

JustBarnt commented 3 weeks ago

Here is a repo just using minimal init.lua to reproduce

I am using Windows 11

Can reproduce with Wezterm and Windows 11

Repo: https://github.com/JustBarnt/nvim-noice-min

: nvim -v
NVIM v0.11.0-dev-783+g0ade8fed1
Build type: RelWithDebInfo
LuaJIT 2.1.1724512491
Run "nvim -V1 -v" for more info

Edit: I also tested this in Alacritty as well which the issue also exists there as well.

dpetka2001 commented 3 weeks ago

@JustBarnt I tried your minimal repo but could not reproduce. I'm using same version of Neovim like you on Linux Mint 21.3 and latest Kitty terminal. Here's a screencast showing the process

Screencast_2024-09-18-19-12-50.webm

JustBarnt commented 3 weeks ago

@dpetka2001 Correct this appears to be an issue that seems limited to Mac OS and Windows for some reason.

I can reproduce the issue within Wezterm and Windows Terminal

I updated my original comment to clarify

gotgenes commented 3 weeks ago

@folke Thanks for your reply.

Install Noice with LazyVim

I need a proper repro. Not a LAzyVim install.

Does the issue trigger with the provided repro?

Yes, it does. My apologies. In my haste, I forgot to update the instructions to say use the minimal repro. I have edited to correct this.

And like I said, please use a recent nightly to reproduce.

I also reproduced on nightly from Neovim's releases:

NVIM v0.11.0-dev-783+g0ade8fed1
Build type: RelWithDebInfo
LuaJIT 2.1.1724512491
Run "nvim -V1 -v" for more info
gotgenes commented 3 weeks ago

I'm also confirming that pinning noice to v4.4.7 makes the flickering behavior go away—in both stable and nightly Neovim:

vim.env.LAZY_STDPATH = '.repro'
load(vim.fn.system('curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua'))()

require('lazy.minit').repro({
  spec = {
    { 'folke/noice.nvim', tag = 'v4.4.7', opts = {} },
    -- add any other plugins here
  },
})
dpetka2001 commented 3 weeks ago

Yes, I just tried with latest neovim-nightly and wezterm-nightly installed via scoop on Windows 10 and I can confirm that the issue exists on Windows. Really strange.

folke commented 3 weeks ago

I'm also on linux.

Will look into it tomorrow to see what's happening on Windows.

I'm not going to revert to v4.4.7. The way that used to work was one big hack by hooking into redraw calls. The new way is the way it should work.

JustBarnt commented 3 weeks ago

@folke I actually think I just figured out the cause! Currently testing on Windows with all mentioned terminals! I just need someone to be able to test the PR within linux (to confirm there are no regressions) and on Mac to confirm it fixed it there as well

dpetka2001 commented 3 weeks ago

I tested the linked PR locally and from my short testing I don't see any regression on Linux. Hope I didn't miss something. Folke obviously will have a better opinion on this.

folke commented 3 weeks ago

Yeah indeed, that cursor = true shouldn't be there.

But there's some thing I want to check first.

JustBarnt commented 3 weeks ago

Yeah setting cursor to false works as well.

folke commented 3 weeks ago

@JustBarnt what was the thing that you found to fix it?

JustBarnt commented 3 weeks ago

@folke I found that adding win = Cmdline.win() also fixes the issue.

Not sure what the correct fix per say is. Although it sounds like cursor = false is the correct fix

if not Util.is_search() then
  if vim.api.nvim__redraw then
      vim.api.nvim__redraw({ flush = true, cursor = true, win = Cmdline.win() })
    else
      vim.cmd.redraw()
    end
  end
folke commented 3 weeks ago

@JustBarnt that's also a good idea, but I think it's not really needed.

I just pushed some changes, so would be great if everyone could check if the problem is now gone.

JustBarnt commented 3 weeks ago

@folke Yeah after I read you comment that cursor = true wasn't supposed to be there I had assumed what I had found isn't necessarily the right fix.

I can confirm on Windows with Wezterm, Windows Terminal, and Alacritty the issue is fixed via commit 3373ab5

folke commented 3 weeks ago

Great :) The issue was due to a bad copy-paste I did from the cmdline code.

Glad it's fixed!

But still weird, that the problem didn't show on Linux. The code was indeed just wrong and I would have expected the cursor to be flickering between the real position and the cmdline. But for some reason that didn't happen on Linux. Probably some debounce somewhere specifc to Linux.

gotgenes commented 2 weeks ago

Fix confirmed on my system, too. Thanks, @folke!