Bekaboo/deadcolumn.nvim

Cursor Losing Column Position Issue in Nightly Version

Closed this issue ยท 6 comments

Firstly, I want to express my sincere thanks for this plugin.

Description:
I've encountered an issue where the cursor loses its column position when scrolling down with the plugin active. This problem persists in nightly builds (I've tried multiple recent versions), but it doesn't occur in stable builds.

While I understand nightly builds may have issues, I wanted to report this problem for consideration.

To Reproduce:

  1. Open a Lua file filled with long lines (exceeding 80 columns).
  2. Start editing the file.
  3. Scroll down using the 'j' key down a long line, and the cursor will lose its position and jump to column 0.
Code to Reproduce
mkdir ~/.config/testcolumn
cd ~/.config/testcolumn
touch init.lua
NVIM_APPNAME=testcolumn nvim

init.lua file

vim.opt.number = true
vim.opt.relativenumber = true

local lazypath = vim.fn.stdpath("data") .. "/lazy/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",
		"--branch=stable",
		lazypath,
	})
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
	"Bekaboo/deadcolumn.nvim",
	event = { "InsertEnter" },
	config = function()
		vim.opt.colorcolumn = "80"
		local opts = {
			modes = { "n", "i" },
			blending = {
				threshold = 0.75,
			},
			warning = {
				alpha = 0.1,
			},
		}
		require("deadcolumn").setup(opts)
	end,
})

The video demonstrates that the issue does not exist before activating the plugin. However, after inserting and saving the file, the problem occurs when scrolling down a long line.
Video:

Kapture.2024-02-13.at.11.03.30.mp4

OS: MacOS
term: wezterm
neovim version:

NVIM v0.10.0-dev-2355+g1c7b0b9d5
Build type: RelWithDebInfo
LuaJIT 2.1.1707061634

Thank you

Hi, thanks for your report. Maybe this is related to #4. Need to take a closer look on this, but I am 90% sure the cause is that setting an option will make nvim lose its horizontal cursor position. Maybe we should report this to neovim once I find a minimal repro.

Thank you for the prompt answer
So vim.opt.colorcolumn could be the reason here. I'll do some tests again and check if I can reproduce it in different situations without the plugin.

@bassamsdata deadcolumn has been refactored to use winhl option instead of colorcolumn option now.

This bug has been reported to neovim: neovim/neovim#27470

thank you, I was tinkering with the time thing related to the autocmd of CursorMoved and tried to defer it but yea, the issue persisted.
the minimal.lua file reproduce the issue indeed, thanks again.

Should be fixed by neovim/neovim#27515