Test_Select_Next_Previous_InsertModeMapping fails with vim >= v9.2.0624

Author: DonKultCreated Aug 4, 2026Updated Aug 4, 2026

The test (added back then) fails in newer vim versions due to vim patch 9.2.0624: C-N/C-P cannot be mapped in complete() completion.

In the test <C-N> is remapped to <Down> and then <C-N> is used to browse through the completion items assuming that the selected item will be inserted on the line as is the case if <C-N> isn't remapped.

The mentioned vim patch literally adds documentation that such a remapping can be used to avoid the insertion. This seems also in line with the behavior of vim's native completion even before that vim patch (compare the bare vim test below).

I am not quite sure what the test tries to ensure feature wise and I am certainly not affected by it as a user, so this is mostly a heads up for if and then newer vim versions appear in your CI and it starts 'mysteriously' failing (or, I suppose, but that seems less likely, users show up who depend on this exact behavior?). The solution might simply be to follow the new vim behavior and drop the test (a very similar non-remapping one exists). Alternatively this might give you a little more time to salvage the pieces or plead with vim upstream to reconsider. I have personally opted for skipping the test for the time being.

Reduced test showing the behavior with YCM

Run with vim -Nu vimrc_ycm_minimal.vim ./third_party/ycmd/ycmd/tests/clangd/testdata/basic.cpp assuming you have YouCompleteMe installed as a pack named youcompleteme, but you could just as well load it from the source as the default vimrc_ycm_minimal does.

vim
set encoding=utf-8
syn on

packadd youcompleteme

" Works without the remap
inoremap <C-n> <Down>

function GetLine(id)
	call assert_equal('  foo.c', getline('.'))
endfunction

function PickCompletion(id)
	"call feedkeys("\<Down>")
	call feedkeys("\<C-n>")
	call timer_start(1000, funcref('GetLine'))
endfunction

function TriggerCompletion(id)
	call feedkeys('cl.')
	call timer_start(1000, funcref('PickCompletion'))
endfunction

function SetPosition(id)
	call setpos('.', [0,11,6])
	call timer_start(1000, funcref('TriggerCompletion'))
endfunction

function Wait()
	call timer_start(1000, funcref('SetPosition'))
endfunction
au BufReadPost */basic.cpp call Wait()

Observe the end state: The line used to read foo.c, it now stays at foo..

for comparison: bare vim behavior reproducer

Run as vim -Nu reproducer.vim (note that it needs no file to open, it will operate on an empty buffer)

vim
set encoding=utf-8

function GetLine(id)
        if getline('.') != 'baz'
                throw "Line is: '" . getline('.') . "' should be: 'baz'"
        endif
endfunction

function PickCompletion(id)
        call feedkeys("\<C-n>")
        call timer_start(1000, funcref('GetLine'))
endfunction

function Remap(id)
        inoremap <C-n> <Down>
        call timer_start(1000, funcref('PickCompletion'))
endfunction

function TriggerCompletion(id)
        call feedkeys("\<C-n>")
        call timer_start(1000, funcref('Remap'))
endfunction

function Setup()
        call feedkeys("ifoo\<Enter>bar\<Enter>baz\<Enter>ball\<Enter>ba")
        call timer_start(1000, funcref('TriggerCompletion'))
endfunction

call Setup()

Note that it always throws as the expectation is never meet with the remap - after or before the vim patch.

OS version, distribution, etc.

Debian unstable as of today, crucially vim 2:9.2.0858-1, vim-youcompleteme & ycmd are both at their current git master (ignore the version numbers they have if you see them, they are misleading) ~ but as usual somewhat heavily patched to make them work as Debian packages rather than git checkouts. These details do not really seem to matter through, but if you prefer you could reproduce the setup starting with any current Debian unstable base in a chroot/docker/whatever and apt install vim-nox vim-youcompleteme. That is as such not that different from your CI, just that you use Ubuntu as base but they will pick this up from Debian in a short while (if they haven't already) and ship it in a release eventually.

Output of `vim --version`

As there are multiple different vim variants in Debian one can pick from: This is the vim-nox variant – as in the whole kitchen sink included with python and stuff, but no gui, just terminal.

VIM - Vi IMproved 9.2 (2026 Feb 14, compiled Jul 27 2026 10:11:18)
Included patches: 1-858
Modified by [email protected]
Compiled by [email protected]
Huge version without GUI.  Features included (+) or not (-):
+acl                +float              +mouse_urxvt        -tag_old_static
+arabic             +folding            +mouse_xterm        +tcl
+autochdir          -footer             -mouseshape         +termguicolors
+autocmd            +fork()             +multi_byte         +terminal
-autoservername     +gettext            +multi_lang         +terminfo
-balloon_eval       -hangul_input       -mzscheme           +termresponse
+balloon_eval_term  +iconv              +netbeans_intg      +textobjects
-browse             +image              +num64              +textprop
++builtin_terms     -image_cairo        +packages           +timers
+byte_offset        -image_gdi          +path_extra         +title
+channel            -image_gdk          +perl               -toolbar
+cindent            +image_kitty        +persistent_undo    +user_commands
+clientserver       +image_sixel        +popupwin           +vartabs
-clipboard          +insert_expand      +postscript         +vertsplit
+clipboard_provider +ipv6               +printer            +vim9script
+cmdline_compl      +job                +profile            +viminfo
+cmdline_hist       +jumplist           -python             +virtualedit
+cmdline_info       +keymap             +python3            +visual
+comments           +lambda             +quickfix           +visualextra
+conceal            +langmap            +reltime            +vreplace
+cryptv             +libcall            +rightleft          -wayland
+cscope             +linebreak          +ruby               -wayland_clipboard
+cursorbind         +lispindent         +scrollbind         +wildignore
+cursorshape        +listcmds           +signs              +wildmenu
+dialog_con         +localmap           +smartindent        +windows
+diff               +lua                +socketserver       +writebackup
+digraphs           +menu               +sodium             -X11
-dnd                +mksession          -sound              +xattr
-ebcdic             +modify_fname       +spell              -xfontset
+emacs_tags         +mouse              +startuptime        -xim
+eval               +mouse_dec          +statusline         -xpm
+ex_extra           +mouse_gpm          -sun_workshop       -xsmp
+extra_search       -mouse_jsbterm      +syntax             -xterm_clipboard
-farsi              +mouse_netterm      +tabpanel           -xterm_save
+file_in_path       +mouse_sgr          -tag_any_white      
+find_in_path       -mouse_sysmouse     +tag_binary         
   system vimrc file: "/etc/vim/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
 3rd user vimrc file: "~/.config/vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -Wdate-time -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/reproducible-path/vim-9.2.0858=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -DSYS_VIMRC_FILE=\"/etc/vim/vimrc\" -DSYS_GVIMRC_FILE=\"/etc/vim/gvimrc\" -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 
Linking: gcc -Wl,-E -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lm -ltinfo -lselinux -lsodium -lacl -lattr -lgpm -L/usr/lib -llua5.1 -Wl,-E -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/perl/5.42/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python3.14/config-3.14-x86_64-linux-gnu -lpython3.14 -ldl -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm -lruby-3.3 -lm -lpthread -L/usr/lib 
`:YcmDebugInfo`
Printing YouCompleteMe debug information...                                                                                                                                                       
-- Resolve completions: On demand                                                                                                                                                                 
-- Client logfile: /tmp/ycm_op1mly8z.log                                                                                                                                                          
-- Server Python interpreter: /usr/bin/python3                                                                                                                                                    
-- Server Python version: 3.14.6                                                                                                                                                                  
-- Server has Clang support compiled in: True                                                                                                                                                     
-- Clang version: Debian clang version 21.1.8 (10)                                                                                                                                                
-- Extra configuration file found and loaded                                                                                                                                                      
-- Extra configuration path: /usr/lib/ycmd/ycm_extra_conf.py                                                                                                                                      
-- C-family completer debug information:                                                                                                                                                          
--   Clangd running                                                                                                                                                                               
--   Clangd process ID: 30376                                                                                                                                                                     
--   Clangd executable: ['/usr/bin/clangd-22', '-header-insertion-decorators=0', '-limit-results=500']                                                                                            
--   Clangd logfiles:                                                                                                                                                                             
--     /tmp/clangd_stderromktsyc5.log                                                                                                                                                             
--   Clangd Server State: Initialized                                                                                                                                                             
--   Clangd Project Directory: <redacted>                                                                                                                                      
--   Clangd Open Workspaces: {'<redacted>'}                                                                                                                                       
--   Clangd Settings: {}                                                                                                                                                                          
--   Clangd Compilation Command: ['clang-tool', '--driver-mode=g++', <redacted> ]                                                                                                                                                                               
-- Server running at: http://127.0.0.1:35165                                                                                                                                                      
-- Server process ID: 30358                                                                                                                                                                       
-- Server logfiles:                                                                                                                                                                               
--   /tmp/ycmd_35165_stdout_8ls9247b.log                                                                                                                                                          
--   /tmp/ycmd_35165_stderr_c82dsk05.log                                                                                                                                                          
-- Semantic highlighting supported: True                                                                                                                                                          
-- Virtual text supported: True                                                                                                                                                                   
-- Popup windows supported: True

Disclaimer: This is the gist of the CI guarding testing transition failing in Debian and me and the vim maintainer trying to make sense of it, eventually leading to this conclusion ~ in case you absolutely want to know how the sausage is made: debbugs#1142936.