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

d809c0a903
This commit is contained in:
zeertzjq
2023-08-27 20:04:44 +08:00
committed by GitHub
parent 4c69279f97
commit 1f49c98036
3 changed files with 98 additions and 6 deletions

View File

@@ -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 {