Skip to content

Commit

Permalink
patch 9.0.0896: test for home key fails when 'term' is "tmux"
Browse files Browse the repository at this point in the history
Problem:    Test for home key fails when 'term' is "tmux".
Solution:   Only save termcap entries that exist.  Adjust code for xHome to
            what xterm uses. (closes #11566)
  • Loading branch information
brammool committed Nov 17, 2022
1 parent 780154b commit 1d8765d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/testdir/test_termcodes.vim
Expand Up @@ -2534,29 +2534,31 @@ endfunc
func Test_home_key_works()
" The '@' character in K_HOME must only match "1" when followed by ";",
" otherwise this code for Home is not recognized: "<Esc>[1~"
" Set termcap values like "xterm" uses them.
let save_kh = &t_kh
let save_K1 = &t_K1
let save_k2 = &t_k2
let save_k3 = &t_k3
let save_end = &t_@7
" Set termcap values like "xterm" uses them. Except using F2 for xHome,
" because that termcap entry can't be set here.
let save_K1 = exists('&t_K1') ? &t_K1 : ''
let save_kh = exists('&t_kh') ? &t_kh : ''
let save_k2 = exists('&t_k2') ? &t_k2 : ''
let save_k3 = exists('&t_k3') ? &t_k3 : ''
let save_end = exists('&t_@7') ? &t_@7 : ''

let &t_K1 = "\<Esc>[1;*~" " <kHome>
let &t_kh = "\<Esc>[@;*H" " <Home>
let &t_k2 = "\<Esc>O*H[1;*~" " use <F2> for <xHome>
let &t_k2 = "\<Esc>O*H" " use <F2> for <xHome>
let &t_k3 = "\<Esc>[7;*~" " use <F3> for <zHome>
let &t_@7 = "\<Esc>[@;*F" " <End>

new
call feedkeys("i\<C-K>\<Esc>OH\n\<Esc>", 'tx')
call feedkeys("i\<C-K>\<Esc>[1~\n\<Esc>", 'tx')
call assert_equal([
\ '<Home>',
\ '<F2>',
\ '<kHome>',
\ ''], getline(1, '$'))

bwipe!
let &t_kh = save_kh
let &t_K1 = save_K1
let &t_kh = save_kh
let &t_k2 = save_k2
let &t_k3 = save_k3
let &t_@7 = save_end
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -695,6 +695,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
896,
/**/
895,
/**/
Expand Down

0 comments on commit 1d8765d

Please sign in to comment.