@@ -194,25 +194,30 @@ function ChunkMod:createAutocmd()
194194 self :notify (" [hlchunk.chunk]: no parser for " .. vim .bo [bufnr ].ft , nil , { once = true })
195195 end
196196 end
197- local debounce_render_cb = debounce (render_cb , self .conf .delay )
198- local debounce_render_cb_with_pre_hook = function (event , opts )
197+ local db_render_cb = debounce (render_cb , self .conf .delay , false )
198+ local db_render_cb_imm = debounce (render_cb , self .conf .delay , true )
199+ local db_render_cb_with_pre_hook = function (event , opts )
199200 opts = opts or { lazy = false }
200201 local bufnr = event .buf
201202 if not (api .nvim_buf_is_valid (bufnr ) and self :shouldRender (bufnr )) then
202203 return
203204 end
204- debounce_render_cb (event , opts )
205+ if opts .lazy then
206+ db_render_cb (event , opts )
207+ else
208+ db_render_cb_imm (event , opts )
209+ end
205210 end
206211 api .nvim_create_autocmd ({ " CursorMovedI" , " CursorMoved" }, {
207212 group = self .meta .augroup_name ,
208213 callback = function (e )
209- debounce_render_cb_with_pre_hook (e , { lazy = true })
214+ db_render_cb_with_pre_hook (e , { lazy = true })
210215 end ,
211216 })
212217 api .nvim_create_autocmd ({ " TextChangedI" , " TextChanged" }, {
213218 group = self .meta .augroup_name ,
214219 callback = function (e )
215- debounce_render_cb_with_pre_hook (e , { lazy = false })
220+ db_render_cb_with_pre_hook (e , { lazy = false })
216221 end ,
217222 })
218223 api .nvim_create_autocmd ({ " UIEnter" , " BufWinEnter" }, {
0 commit comments