]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.1.1251: no test for completion of mapping keys v8.1.1251
authorBram Moolenaar <Bram@vim.org>
Fri, 3 May 2019 13:13:57 +0000 (15:13 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 3 May 2019 13:13:57 +0000 (15:13 +0200)
Problem:    No test for completion of mapping keys.
Solution:   Add a test.  Also clean up the code.

src/getchar.c
src/proto/term.pro
src/term.c
src/testdir/test_cmdline.vim
src/version.c

index a1ffced14ac1d867bf007f34b7c7ee38ebd0e90f..776e4e68416366a9cb09532992e3a956748423dc 100644 (file)
@@ -4263,7 +4263,7 @@ set_context_in_map_cmd(
 }
 
 /*
- * Find all mapping/abbreviation names that match regexp 'prog'.
+ * Find all mapping/abbreviation names that match regexp "regmatch"'.
  * For command line expansion of ":[un]map" and ":[un]abbrev" in all modes.
  * Return OK if matches found, FAIL otherwise.
  */
@@ -4343,7 +4343,7 @@ ExpandMappings(
            {
                if (mp->m_mode & expand_mapmodes)
                {
-                   p = translate_mapping(mp->m_keys, TRUE);
+                   p = translate_mapping(mp->m_keys);
                    if (p != NULL && vim_regexec(regmatch, p, (colnr_T)0))
                    {
                        if (round == 1)
index 1b8ab5f0dd833f9a6852761224491cbacd1c0841..136a9695ef4a66a430280c7cc7bccc886da30aeb 100644 (file)
@@ -74,7 +74,7 @@ char_u *replace_termcodes(char_u *from, char_u **bufp, int from_part, int do_lt,
 int find_term_bykeys(char_u *src);
 void show_termcodes(void);
 int show_one_termcode(char_u *name, char_u *code, int printit);
-char_u *translate_mapping(char_u *str, int expmap);
+char_u *translate_mapping(char_u *str);
 void update_tcap(int attr);
 void swap_tcap(void);
 guicolor_T gui_get_color_cmn(char_u *name);
index 6fa519b4f81c4f856c2b86d2a709fad91e15cbc9..08a55632fb765398b3b6ef7b0ada3e35248fa077 100644 (file)
@@ -6629,22 +6629,20 @@ check_for_codes_from_term(void)
 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
 /*
  * Translate an internal mapping/abbreviation representation into the
- * corresponding external one recognized by :map/:abbrev commands;
- * respects the current B/k/< settings of 'cpoption'.
+ * corresponding external one recognized by :map/:abbrev commands.
+ * Respects the current B/k/< settings of 'cpoption'.
  *
  * This function is called when expanding mappings/abbreviations on the
- * command-line, and for building the "Ambiguous mapping..." error message.
+ * command-line.
  *
- * It uses a growarray to build the translation string since the
- * latter can be wider than the original description. The caller has to
- * free the string afterwards.
+ * It uses a growarray to build the translation string since the latter can be
+ * wider than the original description. The caller has to free the string
+ * afterwards.
  *
  * Returns NULL when there is a problem.
  */
     char_u *
-translate_mapping(
-    char_u     *str,
-    int                expmap)  /* TRUE when expanding mappings on command-line */
+translate_mapping(char_u *str)
 {
     garray_T   ga;
     int                c;
@@ -6691,7 +6689,7 @@ translate_mapping(
            }
            if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL)
            {
-               if (expmap && cpo_special)
+               if (cpo_special)
                {
                    ga_clear(&ga);
                    return NULL;
@@ -6703,7 +6701,7 @@ translate_mapping(
            }
            if (IS_SPECIAL(c) || modifiers)     /* special key */
            {
-               if (expmap && cpo_special)
+               if (cpo_special)
                {
                    ga_clear(&ga);
                    return NULL;
index 3a849cbd15647216395a2b49ae6f548d18907511..f9fd80d2db0b77a5307df5e002333cdd965418e4 100644 (file)
@@ -77,6 +77,42 @@ func Test_map_completion()
   call assert_equal('"map <special> <nowait>', getreg(':'))
   call feedkeys(":map <silent> <sp\<Tab>\<Home>\"\<CR>", 'xt')
   call assert_equal('"map <silent> <special>', getreg(':'))
+
+  map ,f commaf
+  map ,g commaf
+  call feedkeys(":map ,\<Tab>\<Home>\"\<CR>", 'xt')
+  call assert_equal('"map ,f', getreg(':'))
+  call feedkeys(":map ,\<Tab>\<Tab>\<Home>\"\<CR>", 'xt')
+  call assert_equal('"map ,g', getreg(':'))
+  unmap ,f
+  unmap ,g
+
+  set cpo-=< cpo-=B cpo-=k
+  map <Left> left
+  call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
+  call assert_equal('"map <Left>', getreg(':'))
+  unmap <Left>
+
+  set cpo+=<
+  map <Left> left
+  call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
+  call assert_equal('"map <Left>', getreg(':'))
+  unmap <Left>
+  set cpo-=<
+
+  set cpo+=B
+  map <Left> left
+  call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
+  call assert_equal('"map <Left>', getreg(':'))
+  unmap <Left>
+  set cpo-=B
+
+  set cpo+=k
+  map <Left> left
+  call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
+  call assert_equal('"map <Left>', getreg(':'))
+  unmap <Left>
+  set cpo-=k
 endfunc
 
 func Test_match_completion()
index 2fee19b5c1a7dff6189e5e094fa5aafce72c64a9..13b35d57c6f8e38077985b0e1308e0689c0d314b 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1251,
 /**/
     1250,
 /**/