diff options
author | Sean Dewar <seandewar@users.noreply.github.com> | 2023-04-18 10:01:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-18 10:01:42 +0100 |
commit | 9033d5eccc505d31b4a95d9fd23a7e2a8d2f282c (patch) | |
tree | 70b76b061e9b54c57baa2ea17b5e2e6f74612e79 /src | |
parent | d4eff4052a29079e108b5efcb030f07643978994 (diff) | |
parent | 65dd3c1180cef5ec15a46bd278ab3a0cb1c3460d (diff) | |
download | rneovim-9033d5eccc505d31b4a95d9fd23a7e2a8d2f282c.tar.gz rneovim-9033d5eccc505d31b4a95d9fd23a7e2a8d2f282c.tar.bz2 rneovim-9033d5eccc505d31b4a95d9fd23a7e2a8d2f282c.zip |
Merge pull request #23005 from seandewar/fix-ruf-cmdline-pos
fix(ruler): fix some ruler issues with no statusline
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/drawscreen.c | 8 | ||||
-rw-r--r-- | src/nvim/statusline.c | 16 |
2 files changed, 14 insertions, 10 deletions
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index 5ced55b2c7..810175aeba 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -1052,11 +1052,11 @@ int showmode(void) clear_showcmd(); } - // If the last window has no status line and global statusline is disabled, + // If the current or last window has no status line and global statusline is disabled, // the ruler is after the mode message and must be redrawn - win_T *last = curwin->w_floating ? curwin : lastwin_nofloating(); - if (redrawing() && last->w_status_height == 0 && global_stl_height() == 0) { - win_redr_ruler(last); + win_T *ruler_win = curwin->w_status_height == 0 ? curwin : lastwin_nofloating(); + if (redrawing() && ruler_win->w_status_height == 0 && global_stl_height() == 0) { + win_redr_ruler(ruler_win); } redraw_cmdline = false; diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index feb67ad6fa..e809922be3 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -348,7 +348,8 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) } else { row = is_stl_global ? (Rows - (int)p_ch - 1) : W_ENDROW(wp); fillchar = fillchar_status(&attr, wp); - maxwidth = is_stl_global ? Columns : wp->w_width; + const bool in_status_line = wp->w_status_height != 0 || is_stl_global; + maxwidth = in_status_line && !is_stl_global ? wp->w_width : Columns; stl_clear_click_defs(wp->w_status_click_defs, wp->w_status_click_defs_size); wp->w_status_click_defs = stl_alloc_click_defs(wp->w_status_click_defs, maxwidth, &wp->w_status_click_defs_size); @@ -374,8 +375,8 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) if (col < (maxwidth + 1) / 2) { col = (maxwidth + 1) / 2; } - maxwidth = maxwidth - col; - if (!wp->w_status_height && !is_stl_global) { + maxwidth -= col; + if (!in_status_line) { grid = &msg_grid_adj; row = Rows - 1; maxwidth--; // writing in last column may cause scrolling @@ -388,7 +389,9 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) opt_scope = ((*wp->w_p_stl != NUL) ? OPT_LOCAL : 0); } - col += is_stl_global ? 0 : wp->w_wincol; + if (in_status_line && !is_stl_global) { + col += wp->w_wincol; + } } if (maxwidth <= 0) { @@ -494,7 +497,8 @@ void win_redr_ruler(win_T *wp) // Don't draw the ruler while doing insert-completion, it might overwrite // the (long) mode message. - if (wp == lastwin && lastwin->w_status_height == 0 && !is_stl_global) { + win_T *ruler_win = curwin->w_status_height == 0 ? curwin : lastwin_nofloating(); + if (wp == ruler_win && ruler_win->w_status_height == 0 && !is_stl_global) { if (edit_submode != NULL) { return; } @@ -507,7 +511,7 @@ void win_redr_ruler(win_T *wp) // Check if not in Insert mode and the line is empty (will show "0-1"). int empty_line = (State & MODE_INSERT) == 0 - && *ml_get_buf(curwin->w_buffer, curwin->w_cursor.lnum, false) == NUL; + && *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, false) == NUL; int width; int row; |