This bug can be reproduced as follows. Run vim with:

vim -u NONE -i NONE -c 'set nocp bt=nofile' -c 'norm 10ablah ' -c 'norm 0' -c 
'nnoremap <M-d> d' -c 'set <M-d>=<Esc>d'

Then run ':exe "norm fb\<M-d>w"'. It should go to the next 'b' and delete the 
word, but it doesn't delete the word. The same problem happens if the <M-d> is 
in a recording, which is how I first encountered it. ':exe "norm \<M-d>w"' 
works as expected.

The bug is in the normal_cmd function in normal.c. After a seek command, it 
checks if there is a multibyte character next in the typeahead. It reads it and 
tries to put it back, but that fails because it was not read correctly because 
it doesn't set no_mapping to zero for vgetorpeek. The patch fixes that and 
solves the bug described.

I also tested the change by repeating the steps above with 'ンlah' instead of 
'blah' as the word, and with 'ン' instead <M-d> as the map, and it held up (i.e. 
didn't work before the patch, but now does work) in both cases. That said, I'm 
not familiar with the multibyte functionality so check my work.

diff --git a/src/normal.c b/src/normal.c
--- a/src/normal.c
+++ b/src/normal.c
@@ -1077,6 +1077,7 @@
            /* When getting a text character and the next character is a
             * multi-byte character, it could be a composing character.
             * However, don't wait for it to arrive. */
+           --no_mapping;
            while (enc_utf8 && lang && (c = vpeekc()) > 0
                                 && (c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1))
            {
@@ -1091,6 +1092,7 @@
                else
                    ca.ncharC2 = c;
            }
+           ++no_mapping;
 #endif
        }
        --no_mapping;

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/normal.c b/src/normal.c
--- a/src/normal.c
+++ b/src/normal.c
@@ -1077,6 +1077,7 @@
 	    /* When getting a text character and the next character is a
 	     * multi-byte character, it could be a composing character.
 	     * However, don't wait for it to arrive. */
+	    --no_mapping;
 	    while (enc_utf8 && lang && (c = vpeekc()) > 0
 				 && (c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1))
 	    {
@@ -1091,6 +1092,7 @@
 		else
 		    ca.ncharC2 = c;
 	    }
+	    ++no_mapping;
 #endif
 	}
 	--no_mapping;

Raspunde prin e-mail lui