From ce0a221aff0d0dc526dbb77943b29326f4dcfd49 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Wed, 14 Feb 2024 11:12:24 -0600 Subject: [PATCH] refactor: remove the hacky sync call to set virtual indents On the current version of nightly (at the time of writing this is NVIM v0.10.0-dev-2361+ga376d979b) the synchronous call doesn't seem to have any value. Using only a scheduled call is seemingly smooth now -- perhaps when I made the original commit I had something wrong with my configuration or perhaps upstream Neovim fixed whatever was causing some choppiness? Another note is that `on_lines` in `nvim_buf_attach` can have `textlock` restrictions and more applied, thus we really should just use `vim.schedule` only anyhow. --- lua/orgmode/ui/virtual_indent.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lua/orgmode/ui/virtual_indent.lua b/lua/orgmode/ui/virtual_indent.lua index 250fd365b..3960a1d59 100644 --- a/lua/orgmode/ui/virtual_indent.lua +++ b/lua/orgmode/ui/virtual_indent.lua @@ -128,10 +128,7 @@ function VirtualIndent:attach() if not self._attached then return true end - -- HACK: By calling `set_indent` twice, once synchronously and once in `vim.schedule` we get smooth usage of the - -- virtual indent in most cases and still properly handle undo redo. Unfortunately this is called *early* when - -- `undo` or `redo` is used causing the padding to be incorrect for some headlines. - self:set_indent(start_line, end_line) + vim.schedule(function() self:set_indent(start_line, end_line) end)