summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.1251
blob: 4deb14e8c417d1da9bd51f462ab2bad1b6185290 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
To: vim_dev@googlegroups.com
Subject: Patch 8.1.1251
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.1251
Problem:    No test for completion of mapping keys.
Solution:   Add a test.  Also clean up the code.
Files:	    src/getchar.c, src/term.c, src/proto/term.pro,
            src/testdir/test_cmdline.vim


*** ../vim-8.1.1250/src/getchar.c	2019-04-29 21:58:37.667769672 +0200
--- src/getchar.c	2019-05-03 14:49:32.298980123 +0200
***************
*** 4263,4269 ****
  }
  
  /*
!  * 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.
   */
--- 4263,4269 ----
  }
  
  /*
!  * 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,4349 ****
  	    {
  		if (mp->m_mode & expand_mapmodes)
  		{
! 		    p = translate_mapping(mp->m_keys, TRUE);
  		    if (p != NULL && vim_regexec(regmatch, p, (colnr_T)0))
  		    {
  			if (round == 1)
--- 4343,4349 ----
  	    {
  		if (mp->m_mode & expand_mapmodes)
  		{
! 		    p = translate_mapping(mp->m_keys);
  		    if (p != NULL && vim_regexec(regmatch, p, (colnr_T)0))
  		    {
  			if (round == 1)
*** ../vim-8.1.1250/src/term.c	2019-05-02 20:24:08.624617859 +0200
--- src/term.c	2019-05-03 14:49:53.686860278 +0200
***************
*** 6629,6650 ****
  #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'.
   *
   * This function is called when expanding mappings/abbreviations on the
!  * command-line, and for building the "Ambiguous mapping..." error message.
   *
!  * 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 */
  {
      garray_T	ga;
      int		c;
--- 6629,6648 ----
  #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'.
   *
   * This function is called when expanding mappings/abbreviations on the
!  * 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.
   *
   * Returns NULL when there is a problem.
   */
      char_u *
! translate_mapping(char_u *str)
  {
      garray_T	ga;
      int		c;
***************
*** 6691,6697 ****
  	    }
  	    if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL)
  	    {
! 		if (expmap && cpo_special)
  		{
  		    ga_clear(&ga);
  		    return NULL;
--- 6689,6695 ----
  	    }
  	    if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL)
  	    {
! 		if (cpo_special)
  		{
  		    ga_clear(&ga);
  		    return NULL;
***************
*** 6703,6709 ****
  	    }
  	    if (IS_SPECIAL(c) || modifiers)	/* special key */
  	    {
! 		if (expmap && cpo_special)
  		{
  		    ga_clear(&ga);
  		    return NULL;
--- 6701,6707 ----
  	    }
  	    if (IS_SPECIAL(c) || modifiers)	/* special key */
  	    {
! 		if (cpo_special)
  		{
  		    ga_clear(&ga);
  		    return NULL;
*** ../vim-8.1.1250/src/proto/term.pro	2018-08-21 13:09:06.254115882 +0200
--- src/proto/term.pro	2019-05-03 14:49:56.962841925 +0200
***************
*** 74,80 ****
  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);
  void update_tcap(int attr);
  void swap_tcap(void);
  guicolor_T gui_get_color_cmn(char_u *name);
--- 74,80 ----
  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);
  void update_tcap(int attr);
  void swap_tcap(void);
  guicolor_T gui_get_color_cmn(char_u *name);
*** ../vim-8.1.1250/src/testdir/test_cmdline.vim	2019-03-28 21:26:19.252618909 +0100
--- src/testdir/test_cmdline.vim	2019-05-03 15:12:43.791275271 +0200
***************
*** 77,82 ****
--- 77,118 ----
    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()
*** ../vim-8.1.1250/src/version.c	2019-05-03 13:44:06.560890132 +0200
--- src/version.c	2019-05-03 15:13:05.683157641 +0200
***************
*** 769,770 ****
--- 769,772 ----
  {   /* Add new patch number below this line */
+ /**/
+     1251,
  /**/

-- 
My girlfriend told me I should be more affectionate.
So I got TWO girlfriends.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///