diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2024-11-23 23:03:46 +0100 |
---|---|---|
committer | luukvbaal <luukvbaal@gmail.com> | 2025-02-25 13:09:01 +0100 |
commit | f58e7d5fac1c4f63f0ba3e59134591239182910e (patch) | |
tree | 1b180a27cb3c4f4f521188b8e6416d3adfc79206 /src/nvim/edit.c | |
parent | a31ccc3b1f65fd86780c03fec9c6e1bf56e30e35 (diff) | |
download | rneovim-f58e7d5fac1c4f63f0ba3e59134591239182910e.tar.gz rneovim-f58e7d5fac1c4f63f0ba3e59134591239182910e.tar.bz2 rneovim-f58e7d5fac1c4f63f0ba3e59134591239182910e.zip |
feat(marks): add conceal_lines to nvim_buf_set_extmark()
Implement an extmark property that conceals lines vertically.
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r-- | src/nvim/edit.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 6277cd83b6..af3471184d 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -17,6 +17,7 @@ #include "nvim/change.h" #include "nvim/charset.h" #include "nvim/cursor.h" +#include "nvim/decoration.h" #include "nvim/digraph.h" #include "nvim/drawscreen.h" #include "nvim/edit.h" @@ -2586,15 +2587,15 @@ int oneleft(void) return OK; } -/// Move the cursor up "n" lines in window "wp". -/// Takes care of closed folds. -void cursor_up_inner(win_T *wp, linenr_T n) +/// Move the cursor up "n" lines in window "wp". Takes care of closed folds. +/// Skips over concealed lines when "skip_conceal" is true. +void cursor_up_inner(win_T *wp, linenr_T n, bool skip_conceal) { linenr_T lnum = wp->w_cursor.lnum; if (n >= lnum) { lnum = 1; - } else if (hasAnyFolding(wp)) { + } else if (win_lines_concealed(wp)) { // Count each sequence of folded lines as one logical line. // go to the start of the current fold @@ -2603,6 +2604,7 @@ void cursor_up_inner(win_T *wp, linenr_T n) while (n--) { // move up one line lnum--; + n += skip_conceal && decor_conceal_line(wp, lnum - 1, true); if (lnum <= 1) { break; } @@ -2628,7 +2630,7 @@ int cursor_up(linenr_T n, bool upd_topline) if (n > 0 && curwin->w_cursor.lnum <= 1) { return FAIL; } - cursor_up_inner(curwin, n); + cursor_up_inner(curwin, n, false); // try to advance to the column we want to be at coladvance(curwin, curwin->w_curswant); @@ -2640,16 +2642,16 @@ int cursor_up(linenr_T n, bool upd_topline) return OK; } -/// Move the cursor down "n" lines in window "wp". -/// Takes care of closed folds. -void cursor_down_inner(win_T *wp, int n) +/// Move the cursor down "n" lines in window "wp". Takes care of closed folds. +/// Skips over concealed lines when "skip_conceal" is true. +void cursor_down_inner(win_T *wp, int n, bool skip_conceal) { linenr_T lnum = wp->w_cursor.lnum; linenr_T line_count = wp->w_buffer->b_ml.ml_line_count; if (lnum + n >= line_count) { lnum = line_count; - } else if (hasAnyFolding(wp)) { + } else if (win_lines_concealed(wp)) { linenr_T last; // count each sequence of folded lines as one logical line @@ -2659,6 +2661,7 @@ void cursor_down_inner(win_T *wp, int n) } else { lnum++; } + n += skip_conceal && decor_conceal_line(wp, lnum - 1, true); if (lnum >= line_count) { break; } @@ -2680,7 +2683,7 @@ int cursor_down(int n, bool upd_topline) if (n > 0 && lnum >= curwin->w_buffer->b_ml.ml_line_count) { return FAIL; } - cursor_down_inner(curwin, n); + cursor_down_inner(curwin, n, false); // try to advance to the column we want to be at coladvance(curwin, curwin->w_curswant); |