fix(decorator): open fold should redraw at once (#132)

This commit is contained in:
kevinhwang91 2023-05-06 01:15:28 +08:00
parent 9e829d5cfa
commit 138b39f5b2
2 changed files with 7 additions and 4 deletions

View file

@ -72,8 +72,9 @@ local function onEnd(name, tick)
local bufnr = data.bufnr
local fb = fold.get(bufnr)
utils.winCall(winid, function()
local folded = self:computeFoldedLnums(fb, winid, data.rows)
log.debug('folded lnum:', folded)
local folded
folded, needRedraw = self:computeFoldedLnums(fb, winid, data.rows)
log.debug('folded lnums:', folded, 'didOpen:', needRedraw)
if #folded == 0 then
self:clearCursorFoldedLineHighlight(bufnr, winid)
return
@ -228,7 +229,7 @@ function Decorator:computeFoldedLnums(fb, winid, rows)
if didOpen then
fb:syncFoldedLines(winid)
end
return folded
return folded, didOpen
end
---@diagnostic disable-next-line: unused-local

View file

@ -189,13 +189,15 @@ end
---@param lnum number
---@return boolean
function FoldBuffer:openFold(lnum)
local folded = false
local fl = self.foldedLines[lnum]
if fl then
folded = self.foldedLines[lnum] ~= nil
fl:deleteVirtText()
self.foldedLineCount = self.foldedLineCount - 1
self.foldedLines[lnum] = false
end
return fl ~= nil
return folded
end
---