refactor: add win_T argument to setcursor_mayforce()

This commit is contained in:
Luuk van Baal
2024-04-10 11:41:48 +02:00
parent d5063f4b29
commit 7b14eb543d
3 changed files with 12 additions and 12 deletions

View File

@@ -821,25 +821,25 @@ static void win_redr_border(win_T *wp)
/// Set cursor to its position in the current window. /// Set cursor to its position in the current window.
void setcursor(void) void setcursor(void)
{ {
setcursor_mayforce(false); setcursor_mayforce(curwin, false);
} }
/// Set cursor to its position in the current window. /// Set cursor to its position in the current window.
/// @param force when true, also when not redrawing. /// @param force when true, also when not redrawing.
void setcursor_mayforce(bool force) void setcursor_mayforce(win_T *wp, bool force)
{ {
if (force || redrawing()) { if (force || redrawing()) {
validate_cursor(curwin); validate_cursor(wp);
ScreenGrid *grid = &curwin->w_grid; ScreenGrid *grid = &wp->w_grid;
int row = curwin->w_wrow; int row = wp->w_wrow;
int col = curwin->w_wcol; int col = wp->w_wcol;
if (curwin->w_p_rl) { if (wp->w_p_rl) {
// With 'rightleft' set and the cursor on a double-wide character, // With 'rightleft' set and the cursor on a double-wide character,
// position it on the leftmost column. // position it on the leftmost column.
col = curwin->w_width_inner - curwin->w_wcol char *cursor = ml_get_buf(wp->w_buffer, wp->w_cursor.lnum) + wp->w_cursor.col;
- ((utf_ptr2cells(get_cursor_pos_ptr()) == 2 col = wp->w_width_inner - wp->w_wcol - ((utf_ptr2cells(cursor) == 2
&& vim_isprintc(gchar_cursor())) ? 2 : 1); && vim_isprintc(utf_ptr2char(cursor))) ? 2 : 1);
} }
grid_adjust(&grid, &row, &col); grid_adjust(&grid, &row, &col);

View File

@@ -5886,7 +5886,7 @@ static void ex_equal(exarg_T *eap)
static void ex_sleep(exarg_T *eap) static void ex_sleep(exarg_T *eap)
{ {
if (cursor_valid(curwin)) { if (cursor_valid(curwin)) {
setcursor_mayforce(true); setcursor_mayforce(curwin, true);
} }
int64_t len = eap->line2; int64_t len = eap->line2;

View File

@@ -1281,7 +1281,7 @@ void pum_show_popupmenu(vimmenu_T *menu)
pum_is_drawn = true; pum_is_drawn = true;
pum_grid.zindex = kZIndexCmdlinePopupMenu; // show above cmdline area #23275 pum_grid.zindex = kZIndexCmdlinePopupMenu; // show above cmdline area #23275
pum_redraw(); pum_redraw();
setcursor_mayforce(true); setcursor_mayforce(curwin, true);
int c = vgetc(); int c = vgetc();