chunk not redrawn when toggling a comment line
soifou opened this issue · 6 comments
Describe the bug
The redraw is discarded when toggling one or several lines inside a chunk using the builtin comment (eg gcc
) yielding to a non-continuous vertical line. Undoing restore it though. See video below.
To Reproduce
Steps to reproduce the behavior:
nvim -nu repro.lua repro.lua
local root = vim.fn.fnamemodify('./.repro', ':p')
for _, name in ipairs({ 'config', 'data', 'state', 'cache' }) do
vim.env[('XDG_%s_HOME'):format(name:upper())] = root .. '/' .. name
end
local lazypath = root .. '/plugins/lazy.nvim'
if not vim.uv.fs_stat(lazypath) then
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'--single-branch',
'https://github.com/folke/lazy.nvim.git',
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
local plugins = {
{
'shellRaining/hlchunk.nvim',
opts = {
chunk = {
enable = true,
},
},
}
}
require('lazy').setup(plugins, {
root = root .. '/plugins',
})
vim.opt.termguicolors = true
Screenshots
2024-06-11_08-30-16.mp4
chunk will have diff operation between pre chunk and the new chunk when rendering, when you press gcc
the text changed and autocmd does trigger, but the render char not changed, so actually not render actually, I will figure out how the comment plugin work.
it seems that comment.nvim
use nvim_buf_set_lines()
instead of nvim_buf_set_text()
caused this, the first function will remove extmark when change text, I will take a issue in this repo
FWIW, I don't use any comment plugin but the now builtin comment implementation that comes with nvim 0.10. It use as well nvim_buf_set_lines()
as shown here
I also found that numToStr/Comment.nvim#52 and numToStr/Comment.nvim#110 mentioned this, seems can solve this, but the example I can't fully understand
fix by add lazy field when rendering, if comment a line then re-render with no lazy option passed. and because debounce function, there maybe blink when comment, I will improve in the future
This works great! Thank you so much for the quick fix.