fix(preview): must return empty kind because of diff or marker foldmethod

This commit is contained in:
kevinhwang91 2022-09-19 17:15:57 +08:00
parent 9a12997518
commit f0ae3c77d9
2 changed files with 7 additions and 2 deletions

View file

@ -94,9 +94,13 @@ function FoldBuffer:foldedLine(lnum)
end
---
---@param winid number
---@param lnum number 1-index
---@return UfoFoldingRangeKind|''
function FoldBuffer:lineKind(lnum)
function FoldBuffer:lineKind(winid, lnum)
if utils.isDiffOrMarkerFold(winid) then
return ''
end
local row = lnum - 1
for _, range in ipairs(self.foldRanges) do
if row >= range.startLine and row <= range.endLine then

View file

@ -192,7 +192,8 @@ function Preview:peekFoldedLinesUnderCursor(enter, nextLineIncluded)
if utils.isBufLoaded(floatwin.bufnr) then
api.nvim_buf_clear_namespace(floatwin.bufnr, self.ns, 0, -1)
end
local kind = fb:lineKind(lnum)
local curWinid = api.nvim_get_current_win()
local kind = fb:lineKind(curWinid, lnum)
local isAbove = kind == 'comment'
if not isAbove and nextLineIncluded ~= false then
endLnum = fb:lineCount() == endLnum and endLnum or (endLnum + 1)