From 5fc78d835dfbd14f23844d8146f6cc6b77520c7b Mon Sep 17 00:00:00 2001 From: mohsen <36933074+smoka7@users.noreply.github.com> Date: Mon, 24 Jul 2023 15:59:58 +0000 Subject: [PATCH] fix: consider folded line when geting lines via count --- lua/Comment/utils.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/Comment/utils.lua b/lua/Comment/utils.lua index e95ee2c..1f3afd9 100644 --- a/lua/Comment/utils.lua +++ b/lua/Comment/utils.lua @@ -130,6 +130,10 @@ end function U.get_count_lines(count) local srow = unpack(A.nvim_win_get_cursor(0)) local erow = (srow + count) - 1 + local fold_end = vim.fn.foldclosedend(erow) + if fold_end ~= -1 then + erow = fold_end + 1 + end local lines = A.nvim_buf_get_lines(0, srow - 1, erow, false) return lines, { srow = srow, scol = 0, erow = erow, ecol = 0 }