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

`WinScrolled` event close automatically open folds when scrolling

Open soifou opened this issue 1 year ago • 3 comments

Describe the bug

The commit 4ceee25 seems to have introduce a bug with fold under specific conditions because of the added WinScrolled event.

To Reproduce

  1. Open a relative long buffer with the following modeline, # vim: foldmethod=marker foldlevel=0
  2. Reveal all folds (zR)
  3. Scroll down the buffer to trigger the WinScrolled event
  4. The folds are automatically closed
  5. Remove the new autocmd: :autocmd! hlchunk_indent User WinScrolledY, and repeat step 2 and 3
  6. The folds are untouched

It seems only hlchunk_indent produce this behaviour. Also, when no modeline is used, this work fine :man_shrugging:

soifou avatar Oct 02 '24 16:10 soifou

I have the same problem.

Did you find a fix yet? @soifou

tamton-aquib avatar Dec 20 '24 10:12 tamton-aquib

A workaround is to disable the autocmd after setup:

    config = function(_, opts)
      require('hlchunk').setup(opts)

      local autocmds = vim.api.nvim_get_autocmds({
        group = 'hlchunk_indent',
        event = 'User',
        pattern = 'WinScrolledY',
      })

      if #autocmds then
        vim.api.nvim_del_autocmd(autocmds[1].id)
      end
    end

But then of course sometimes the indent guides aren't rendered after opening folds.

toupeira avatar May 24 '25 02:05 toupeira

I pushed a possible fix at https://github.com/shellRaining/hlchunk.nvim/pull/169, can you test if it solves the problem for you too @soifou @tamton-aquib? 🙇

edit: gave up on this, see https://github.com/shellRaining/hlchunk.nvim/pull/169#issuecomment-2930877385

toupeira avatar May 24 '25 15:05 toupeira