diff --git a/src/nvim/normal.c b/src/nvim/normal.c index ba9dc88014..3f6443de66 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -106,6 +106,9 @@ static int VIsual_mode_orig = NUL; // saved Visual mode # include "normal.c.generated.h" #endif +static const char e_cmdline_window_already_open[] + = N_("E1292: Command-line window is already open"); + static inline void normal_state_init(NormalState *s) { memset(s, 0, sizeof(NormalState)); @@ -6384,6 +6387,10 @@ static void nv_record(cmdarg_T *cap) } if (cap->nchar == ':' || cap->nchar == '/' || cap->nchar == '?') { + if (cmdwin_type != 0) { + emsg(_(e_cmdline_window_already_open)); + return; + } stuffcharReadbuff(cap->nchar); stuffcharReadbuff(K_CMDWIN); } else { diff --git a/test/old/testdir/test_cmdwin.vim b/test/old/testdir/test_cmdwin.vim new file mode 100644 index 0000000000..ef334c774f --- /dev/null +++ b/test/old/testdir/test_cmdwin.vim @@ -0,0 +1,17 @@ +" Tests for editing the command line. + +source check.vim +source screendump.vim + + +func Test_cant_open_cmdwin_in_cmdwin() + try + call feedkeys("q:q::q\", "x!") + catch + let caught = v:exception + endtry + call assert_match('E1292:', caught) +endfunc + + +" vim: shiftwidth=2 sts=2 expandtab