aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/getchar.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-08-04 19:12:35 -0400
committerJustin M. Keyes <justinkz@gmail.com>2019-08-05 01:12:35 +0200
commita724209b5a34e40fe2fff338ff7c5db2bc395bbc (patch)
tree611f76a05587cc6ef5edce26bf9215350c55a886 /src/nvim/getchar.c
parent4c35e6fe6734050b2e633aba330b0e389835fbc4 (diff)
downloadrneovim-a724209b5a34e40fe2fff338ff7c5db2bc395bbc.tar.gz
rneovim-a724209b5a34e40fe2fff338ff7c5db2bc395bbc.tar.bz2
rneovim-a724209b5a34e40fe2fff338ff7c5db2bc395bbc.zip
vim-patch:8.1.1251: test completion of mapping keys #10691
Problem: No test for completion of mapping keys. Solution: Add a test. Also clean up the code. https://github.com/vim/vim/commit/2cb9f0253228478ec27265ff40f59c629874d695
Diffstat (limited to 'src/nvim/getchar.c')
-rw-r--r--src/nvim/getchar.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 7d8342c4dd..f7614fd3e1 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -3558,11 +3558,9 @@ set_context_in_map_cmd (
return NULL;
}
-/*
- * Find all mapping/abbreviation names that match regexp 'prog'.
- * For command line expansion of ":[un]map" and ":[un]abbrev" in all modes.
- * Return OK if matches found, FAIL otherwise.
- */
+// 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.
int ExpandMappings(regmatch_T *regmatch, int *num_file, char_u ***file)
{
mapblock_T *mp;
@@ -3622,7 +3620,7 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char_u ***file)
mp = maphash[hash];
for (; mp; mp = mp->m_next) {
if (mp->m_mode & expand_mapmodes) {
- p = translate_mapping(mp->m_keys, true, CPO_TO_CPO_FLAGS);
+ p = translate_mapping(mp->m_keys, CPO_TO_CPO_FLAGS);
if (p != NULL && vim_regexec(regmatch, p, (colnr_T)0)) {
if (round == 1)
++count;
@@ -4346,16 +4344,15 @@ void add_map(char_u *map, int mode)
// corresponding external one recognized by :map/:abbrev commands.
//
// 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.
static char_u * translate_mapping (
char_u *str,
- int expmap, // True when expanding mappings on command-line
int cpo_flags // Value of various flags present in &cpo
)
{
@@ -4373,12 +4370,8 @@ static char_u * translate_mapping (
modifiers = *++str;
c = *++str;
}
-
+
if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) {
- if (expmap) {
- ga_clear(&ga);
- return NULL;
- }
c = TO_SPECIAL(str[1], str[2]);
if (c == K_ZERO) {
// display <Nul> as ^@
@@ -4387,10 +4380,6 @@ static char_u * translate_mapping (
str += 2;
}
if (IS_SPECIAL(c) || modifiers) { // special key
- if (expmap) {
- ga_clear(&ga);
- return NULL;
- }
ga_concat(&ga, get_special_key_name(c, modifiers));
continue; /* for (str) */
}