vim-patch:9.0.1761: g<kEnd> behaves different from g<end>

Problem:  g<kEnd> behaves different from g<end>
Solution: Make g<kEnd> behave like g<End>

closes: vim/vim#12861

654bdbbd32
This commit is contained in:
zeertzjq
2023-08-21 06:11:23 +08:00
parent 7485fd0518
commit 0c91cb4f03
3 changed files with 10 additions and 5 deletions

View File

@@ -246,7 +246,8 @@ g$ When lines wrap ('wrap' on): To the last character of
instead of going to the end of the line.
When 'virtualedit' is enabled moves to the end of the
screen line.
*g<End>*
*g<End>* *g<kEnd>*
g<End> Like |g$| but to the last non-blank character
instead of the last character.

View File

@@ -5323,7 +5323,7 @@ static void nv_g_dollar_cmd(cmdarg_T *cap)
oparg_T *oap = cap->oap;
int i;
int col_off = curwin_col_off();
const bool flag = cap->nchar == K_END;
const bool flag = cap->nchar == K_END || cap->nchar == K_KEND;
oap->motion_type = kMTCharWise;
oap->inclusive = true;

View File

@@ -4118,20 +4118,24 @@ func Test_normal_click_on_double_width_char()
endfunc
func Test_normal33_g_cmd_nonblank()
" Test that g$ goes to the last non-blank char and g<end> to the last
" Test that g<End> goes to the last non-blank char and g$ to the last
" visible column
20vnew
setlocal nowrap nonumber signcolumn=no
call setline(1, ['fooo fooo fooo fooo fooo fooo fooo fooo '])
exe "normal 0g\<end>"
exe "normal 0g\<End>"
call assert_equal(11, col('.'))
normal 0g$
call assert_equal(20, col('.'))
exe "normal 0g\<kEnd>"
call assert_equal(11, col('.'))
setlocal wrap
exe "normal 0g\<end>"
exe "normal 0g\<End>"
call assert_equal(11, col('.'))
normal 0g$
call assert_equal(20, col('.'))
exe "normal 0g\<kEnd>"
call assert_equal(11, col('.'))
bw!
endfunc