From 8a6cf51a710585fee7edb9d1357791da30f31f44 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 1 Apr 2022 07:11:38 +0800 Subject: 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) https://github.com/vim/vim/commit/30441bb3d5fa73f888b09684db3f54ff5ab48dbc --- src/nvim/move.c | 7 ++++++- src/nvim/testdir/test_listchars.vim | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/move.c b/src/nvim/move.c index 5e02e355bf..eda3298101 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -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); diff --git a/src/nvim/testdir/test_listchars.vim b/src/nvim/testdir/test_listchars.vim index c6e2ebd406..b239c9c6b5 100644 --- a/src/nvim/testdir/test_listchars.vim +++ b/src/nvim/testdir/test_listchars.vim @@ -542,6 +542,12 @@ func Test_listchars_foldcolumn() call VerifyScreenDump(buf, 'Test_listchars_04', {}) call term_sendkeys(buf, "\>") call VerifyScreenDump(buf, 'Test_listchars_05', {}) + call term_sendkeys(buf, "\h") + call term_sendkeys(buf, ":set nowrap foldcolumn=4\") + call term_sendkeys(buf, "15\<") + call VerifyScreenDump(buf, 'Test_listchars_06', {}) + call term_sendkeys(buf, "4\<") + call VerifyScreenDump(buf, 'Test_listchars_07', {}) " clean up call StopVimInTerminal(buf) -- cgit