diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-08-27 20:04:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-27 20:04:44 +0800 |
commit | 1f49c980368616345d8d0e121fed66a2013f9e96 (patch) | |
tree | 0552d0baa97e3c23b447039eb4db340f67811afe /src | |
parent | 4c69279f97e566277a33b81146b26b7ca20de4f3 (diff) | |
download | rneovim-1f49c980368616345d8d0e121fed66a2013f9e96.tar.gz rneovim-1f49c980368616345d8d0e121fed66a2013f9e96.tar.bz2 rneovim-1f49c980368616345d8d0e121fed66a2013f9e96.zip |
vim-patch:9.0.1792: problem with gj/gk/gM and virtual text (#24898)
Problem: Normal mode "gM", "gj", "gk" commands behave incorrectly with
virtual text.
Solution: Use linetabsize() instead of linetabsize_str().
closes: vim/vim#12909
https://github.com/vim/vim/commit/d809c0a90387a23aed21ba37d0b65332fb5dafe7
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/cursor.c | 4 | ||||
-rw-r--r-- | src/nvim/normal.c | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c index 2dc903309e..418d49dfeb 100644 --- a/src/nvim/cursor.c +++ b/src/nvim/cursor.c @@ -115,7 +115,7 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a col = wcol; if ((addspaces || finetune) && !VIsual_active) { - curwin->w_curswant = linetabsize_str(line) + one_more; + curwin->w_curswant = (int)linetabsize(curwin, pos->lnum) + one_more; if (curwin->w_curswant > 0) { curwin->w_curswant--; } @@ -129,7 +129,7 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a && curwin->w_width_inner != 0 && wcol >= (colnr_T)width && width > 0) { - csize = linetabsize_str(line); + csize = (int)linetabsize(curwin, pos->lnum); if (csize > 0) { csize--; } diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 82b930d2ff..0764cbec7a 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2471,7 +2471,7 @@ bool find_decl(char *ptr, size_t len, bool locally, bool thisblock, int flags_ar /// @return true if able to move cursor, false otherwise. static bool nv_screengo(oparg_T *oap, int dir, long dist) { - int linelen = linetabsize_str(get_cursor_line_ptr()); + int linelen = (int)linetabsize(curwin, curwin->w_cursor.lnum); bool retval = true; bool atend = false; int col_off1; // margin offset for first screen line @@ -2535,7 +2535,7 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) } cursor_up_inner(curwin, 1); - linelen = linetabsize_str(get_cursor_line_ptr()); + linelen = (int)linetabsize(curwin, curwin->w_cursor.lnum); if (linelen > width1) { int w = (((linelen - width1 - 1) / width2) + 1) * width2; assert(curwin->w_curswant <= INT_MAX - w); @@ -2568,7 +2568,7 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) if (curwin->w_curswant >= width1) { curwin->w_curswant -= width2; } - linelen = linetabsize_str(get_cursor_line_ptr()); + linelen = (int)linetabsize(curwin, curwin->w_cursor.lnum); } } } @@ -5492,7 +5492,7 @@ static void nv_g_cmd(cmdarg_T *cap) case 'M': oap->motion_type = kMTCharWise; oap->inclusive = false; - i = linetabsize_str(get_cursor_line_ptr()); + i = (int)linetabsize(curwin, curwin->w_cursor.lnum); if (cap->count0 > 0 && cap->count0 <= 100) { coladvance((colnr_T)(i * cap->count0 / 100)); } else { |