Bekaboo / deadcolumn.nvim

A neovim plugin that shows colorcolumn dynamically
GNU General Public License v3.0
285 stars 9 forks source link

Cursor Losing Column Position Issue in Nightly Version #19

Closed bassamsdata closed 8 months ago

bassamsdata commented 8 months ago

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 ```sh mkdir ~/.config/testcolumn cd ~/.config/testcolumn touch init.lua NVIM_APPNAME=testcolumn nvim ``` init.lua file ```lua 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:

https://github.com/Bekaboo/deadcolumn.nvim/assets/105807570/44e07f6e-fef1-45cb-82e4-7cc8bb30047f

OS: MacOS term: wezterm neovim version:

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

Thank you

Bekaboo commented 8 months ago

Hi, thanks for your report. Maybe this is related to https://github.com/Bekaboo/deadcolumn.nvim/issues/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.

bassamsdata commented 8 months ago

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.

Bekaboo commented 8 months ago

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

Bekaboo commented 8 months ago

This bug has been reported to neovim: https://github.com/neovim/neovim/issues/27470

bassamsdata commented 8 months ago

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.

Bekaboo commented 8 months ago

Should be fixed by https://github.com/neovim/neovim/pull/27515