vim-patch:8.2.3122: with 'nowrap' cursor position is unexected in narrow window (#17935)

Problem:    With 'nowrap' cursor position is unexected in narrow window.
            (Leonid V.  Fedorenchik)
Solution:   Put cursor on the last non-empty line. (closes vim/vim#8525)
30441bb3d5
This commit is contained in:
zeertzjq
2022-04-01 07:11:38 +08:00
committed by GitHub
parent dc48330b9d
commit 8a6cf51a71
3 changed files with 103 additions and 46 deletions

View File

@@ -778,8 +778,13 @@ void curs_columns(win_T *wp, int may_scroll)
int textwidth = wp->w_width_inner - extra;
if (textwidth <= 0) {
// No room for text, put cursor in last char of window.
// If not wrapping, the last non-empty line.
wp->w_wcol = wp->w_width_inner - 1;
wp->w_wrow = wp->w_height_inner - 1;
if (wp->w_p_wrap) {
wp->w_wrow = wp->w_height_inner - 1;
} else {
wp->w_wrow = wp->w_height_inner - 1 - wp->w_empty_rows;
}
} else if (wp->w_p_wrap
&& wp->w_width_inner != 0) {
width = textwidth + win_col_off2(wp);