Skip to content

Commit 2528163

Browse files
committed
patch 7.4.1150
Problem: 'langmap' applies to the first character typed in Select mode. (David Watson) Solution: Check for SELECTMODE. (Christian Brabandt, closes #572) Add the 'x' flag to feedkeys().
1 parent d6357e8 commit 2528163

8 files changed

Lines changed: 52 additions & 9 deletions

File tree

runtime/doc/eval.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3099,6 +3099,11 @@ feedkeys({string} [, {mode}]) *feedkeys()*
30993099
if coming from a mapping. This matters for undo,
31003100
opening folds, etc.
31013101
'i' Insert the string instead of appending (see above).
3102+
'x' Execute commands until typeahead is empty. This is
3103+
similar to using ":normal!". You can call feedkeys()
3104+
several times without 'x' and then one time with 'x'
3105+
(possibly with an empty {string}) to execute all the
3106+
typeahead.
31023107
Return value is always 0.
31033108

31043109
filereadable({file}) *filereadable()*

src/ex_docmd.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10225,18 +10225,27 @@ exec_normal_cmd(cmd, remap, silent)
1022510225
char_u *cmd;
1022610226
int remap;
1022710227
int silent;
10228+
{
10229+
/* Stuff the argument into the typeahead buffer. */
10230+
ins_typebuf(cmd, remap, 0, TRUE, silent);
10231+
exec_normal(FALSE);
10232+
}
10233+
#endif
10234+
10235+
#if defined(FEAT_EX_EXTRA) || defined(FEAT_MENU) || defined(FEAT_EVAL) \
10236+
|| defined(PROTO)
10237+
/*
10238+
* Execute normal_cmd() until there is no typeahead left.
10239+
*/
10240+
void
10241+
exec_normal(int was_typed)
1022810242
{
1022910243
oparg_T oa;
1023010244

10231-
/*
10232-
* Stuff the argument into the typeahead buffer.
10233-
* Execute normal_cmd() until there is no typeahead left.
10234-
*/
1023510245
clear_oparg(&oa);
1023610246
finish_op = FALSE;
10237-
ins_typebuf(cmd, remap, 0, TRUE, silent);
10238-
while ((!stuff_empty() || (!typebuf_typed() && typebuf.tb_len > 0))
10239-
&& !got_int)
10247+
while ((!stuff_empty() || ((was_typed || !typebuf_typed())
10248+
&& typebuf.tb_len > 0)) && !got_int)
1024010249
{
1024110250
update_topline_cursor();
1024210251
normal_cmd(&oa, TRUE); /* execute a Normal mode cmd */

src/getchar.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2149,7 +2149,8 @@ vgetorpeek(advance)
21492149
else
21502150
{
21512151
LANGMAP_ADJUST(c1,
2152-
(State & (CMDLINE | INSERT)) == 0);
2152+
(State & (CMDLINE | INSERT)) == 0
2153+
&& get_real_state() != SELECTMODE);
21532154
nolmaplen = 0;
21542155
}
21552156
#endif

src/normal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ normal_cmd(oap, toplevel)
638638
* Get the command character from the user.
639639
*/
640640
c = safe_vgetc();
641-
LANGMAP_ADJUST(c, TRUE);
641+
LANGMAP_ADJUST(c, get_real_state() != SELECTMODE);
642642

643643
/*
644644
* If a mapping was started in Visual or Select mode, remember the length

src/proto/ex_docmd.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ int vim_mkdir_emsg(char_u *name, int prot);
5050
FILE *open_exfile(char_u *fname, int forceit, char *mode);
5151
void update_topline_cursor(void);
5252
void exec_normal_cmd(char_u *cmd, int remap, int silent);
53+
void exec_normal(int was_typed);
5354
int find_cmdline_var(char_u *src, int *usedlen);
5455
char_u *eval_vars(char_u *src, char_u *srcstart, int *usedlen, linenr_T *lnump, char_u **errormsg, int *escaped);
5556
char_u *expand_sfile(char_u *arg);

src/testdir/Make_all.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ NEW_TESTS = test_arglist.res \
173173
test_cdo.res \
174174
test_hardcopy.res \
175175
test_increment.res \
176+
test_langmap.res \
176177
test_perl.res \
177178
test_quickfix.res \
178179
test_syntax.res \

src/testdir/test_langmap.vim

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
" tests for 'langmap'
2+
3+
func Test_langmap()
4+
new
5+
set langmap=}l,^x,%v
6+
7+
call setline(1, ['abc'])
8+
call feedkeys('gg0}^', 'tx')
9+
call assert_equal('ac', getline(1))
10+
11+
" in Replace mode
12+
" need silent! to avoid a delay when entering Insert mode
13+
call setline(1, ['abcde'])
14+
silent! call feedkeys("gg0lR%{z\<Esc>00", 'tx')
15+
call assert_equal('a%{ze', getline(1))
16+
17+
" in Select mode
18+
" need silent! to avoid a delay when entering Insert mode
19+
call setline(1, ['abcde'])
20+
silent! call feedkeys("gg0}%}\<C-G>}^\<Esc>00", 'tx')
21+
call assert_equal('a}^de', getline(1))
22+
23+
quit!
24+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
1150,
744746
/**/
745747
1149,
746748
/**/

0 commit comments

Comments
 (0)