Skip to content

Commit 523bdd4

Browse files
authored
feat: Automatically open fold under cursor (#380)
feat: Automatically open fold under cursor, redraw screen with cursor at center
1 parent e17d713 commit 523bdd4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lua/gitlab/reviewer/init.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ M.jump = function(file_name, line_number, new_buffer)
145145
line_number = number_of_lines
146146
end
147147
vim.api.nvim_win_set_cursor(0, { line_number, 0 })
148+
u.open_fold_under_cursor()
149+
vim.cmd("normal! zz")
148150
end
149151

150152
---Get the data from diffview, such as line information and file name. May be used by

lua/gitlab/utils/init.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,4 +752,10 @@ M.get_nested_field = function(table, field)
752752
end
753753
end
754754

755+
M.open_fold_under_cursor = function()
756+
if vim.fn.foldclosed(vim.fn.line(".")) > -1 then
757+
vim.cmd("normal! zo")
758+
end
759+
end
760+
755761
return M

0 commit comments

Comments
 (0)