]> granicus.if.org Git - vim/commitdiff
patch 7.4.1150 v7.4.1150
authorBram Moolenaar <Bram@vim.org>
Thu, 21 Jan 2016 22:32:32 +0000 (23:32 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 21 Jan 2016 22:32:32 +0000 (23:32 +0100)
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().

runtime/doc/eval.txt
src/ex_docmd.c
src/getchar.c
src/normal.c
src/proto/ex_docmd.pro
src/testdir/Make_all.mak
src/testdir/test_langmap.vim [new file with mode: 0644]
src/version.c

index 5e0be5899c3eb8a6f2f2763063017b5dd0aa6fce..ebd21ae664e74cee44722e0224886c657603bc06 100644 (file)
@@ -3099,6 +3099,11 @@ feedkeys({string} [, {mode}])                            *feedkeys()*
                        if coming from a mapping.  This matters for undo,
                        opening folds, etc.
                'i'     Insert the string instead of appending (see above).
+               'x'     Execute commands until typeahead is empty.  This is
+                       similar to using ":normal!".  You can call feedkeys()
+                       several times without 'x' and then one time with 'x'
+                       (possibly with an empty {string}) to execute all the
+                       typeahead.
                Return value is always 0.
 
 filereadable({file})                                   *filereadable()*
index 837d135218ff8993b917f05d4a134277442d794a..5c61679d7b8c099dcf465ce15574494cd770f3f7 100644 (file)
@@ -10225,18 +10225,27 @@ exec_normal_cmd(cmd, remap, silent)
     char_u     *cmd;
     int                remap;
     int                silent;
+{
+    /* Stuff the argument into the typeahead buffer. */
+    ins_typebuf(cmd, remap, 0, TRUE, silent);
+    exec_normal(FALSE);
+}
+#endif
+
+#if defined(FEAT_EX_EXTRA) || defined(FEAT_MENU) || defined(FEAT_EVAL) \
+       || defined(PROTO)
+/*
+ * Execute normal_cmd() until there is no typeahead left.
+ */
+    void
+exec_normal(int was_typed)
 {
     oparg_T    oa;
 
-    /*
-     * Stuff the argument into the typeahead buffer.
-     * Execute normal_cmd() until there is no typeahead left.
-     */
     clear_oparg(&oa);
     finish_op = FALSE;
-    ins_typebuf(cmd, remap, 0, TRUE, silent);
-    while ((!stuff_empty() || (!typebuf_typed() && typebuf.tb_len > 0))
-                                                                 && !got_int)
+    while ((!stuff_empty() || ((was_typed || !typebuf_typed())
+                   && typebuf.tb_len > 0)) && !got_int)
     {
        update_topline_cursor();
        normal_cmd(&oa, TRUE);  /* execute a Normal mode cmd */
index 70829e18eff521983aa343ae551870d3e72dd9cf..5b5eab3871832585c78064b6b4e7b5cb8ea09baf 100644 (file)
@@ -2149,7 +2149,8 @@ vgetorpeek(advance)
                        else
                        {
                            LANGMAP_ADJUST(c1,
-                                          (State & (CMDLINE | INSERT)) == 0);
+                                          (State & (CMDLINE | INSERT)) == 0
+                                          && get_real_state() != SELECTMODE);
                            nolmaplen = 0;
                        }
 #endif
index ac1a391f26873c8dbce867b27ea825b252abc93d..17cb8d6b8ee461b46aaba8db2abc99da62b42c05 100644 (file)
@@ -638,7 +638,7 @@ normal_cmd(oap, toplevel)
      * Get the command character from the user.
      */
     c = safe_vgetc();
-    LANGMAP_ADJUST(c, TRUE);
+    LANGMAP_ADJUST(c, get_real_state() != SELECTMODE);
 
     /*
      * If a mapping was started in Visual or Select mode, remember the length
index f4d4347250f8c02decca97ce7ad049add53445c1..15e5fc5c04dc8b5f398b6f826429a344e286eb39 100644 (file)
@@ -50,6 +50,7 @@ int vim_mkdir_emsg(char_u *name, int prot);
 FILE *open_exfile(char_u *fname, int forceit, char *mode);
 void update_topline_cursor(void);
 void exec_normal_cmd(char_u *cmd, int remap, int silent);
+void exec_normal(int was_typed);
 int find_cmdline_var(char_u *src, int *usedlen);
 char_u *eval_vars(char_u *src, char_u *srcstart, int *usedlen, linenr_T *lnump, char_u **errormsg, int *escaped);
 char_u *expand_sfile(char_u *arg);
index d02e8d2b40790c8e2f3e15fdba36c9d5cbe0fa38..d7a06eeb47bdfcba61dba626ae9b1e5c13697f76 100644 (file)
@@ -173,6 +173,7 @@ NEW_TESTS = test_arglist.res \
            test_cdo.res \
            test_hardcopy.res \
            test_increment.res \
+           test_langmap.res \
            test_perl.res \
            test_quickfix.res \
            test_syntax.res \
diff --git a/src/testdir/test_langmap.vim b/src/testdir/test_langmap.vim
new file mode 100644 (file)
index 0000000..066c3bf
--- /dev/null
@@ -0,0 +1,24 @@
+" tests for 'langmap'
+
+func Test_langmap()
+  new
+  set langmap=}l,^x,%v
+
+  call setline(1, ['abc'])
+  call feedkeys('gg0}^', 'tx')
+  call assert_equal('ac', getline(1))
+
+  " in Replace mode
+  " need silent! to avoid a delay when entering Insert mode
+  call setline(1, ['abcde'])
+  silent! call feedkeys("gg0lR%{z\<Esc>00", 'tx')
+  call assert_equal('a%{ze', getline(1))
+
+  " in Select mode
+  " need silent! to avoid a delay when entering Insert mode
+  call setline(1, ['abcde'])
+  silent! call feedkeys("gg0}%}\<C-G>}^\<Esc>00", 'tx')
+  call assert_equal('a}^de', getline(1))
+
+  quit!
+endfunc
index 96e0105fb54d6de213e95190a0398198b8c66666..6aee23d435e2db31083a39f814abde0562b9350f 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1150,
 /**/
     1149,
 /**/