Bram,
There are still two open issues with langmaps. One is issue 297
(https://code.google.com/p/vim/issues/detail?id=297), the other one is this one
(https://groups.google.com/d/msg/vim_dev/5D1WSL2gj-A/OgCBNZQEHNEJ)
I have checked the problem and I think the problem is, that mappings won't be
resolved after a multibyte characters have been read. This is caused, by the
fact that vgetorpeek() that resolves mappings, doesn't know about multibyte
chars, since those are only known in the higher level vgetc() function. But
after applying the langmap there, Vim won't check, if the input needs to be
resolved for mappings.
Therefore I changed vgetc() function to resolve langmaps after the multibyte
chars have been read correctly and once this changed the input character and a
mapping for that character exists, put that character again into the typeahead
buffer and run vgetorpeek() again.
Attached patch includes 2 tests, that are taken from the above issues and
demonstrate the problem.
Best,
Christian
--
--
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/getchar.c b/src/getchar.c
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -1812,6 +1812,22 @@ vgetc()
}
--no_mapping;
c = (*mb_ptr2char)(buf);
+ c2 = c;
+ LANGMAP_ADJUST(c, (State & INSERT) == 0);
+ if (c2 != c)
+ {
+ /* need to check for a mapping */
+ mapblock_T *mp;
+ i = (*mb_char2bytes)(c, buf);
+ buf[i] = NUL;
+ if (check_map(buf, State, FALSE, TRUE, FALSE, &mp, NULL) != NULL)
+ {
+ /* mapping found, insert into typebuf */
+ ins_typebuf(buf, REMAP_YES, 0, TRUE, mp->m_silent);
+ typebuf_was_filled = TRUE;
+ continue;
+ }
+ }
}
#endif
diff --git a/src/testdir/test_mapping.in b/src/testdir/test_mapping.in
--- a/src/testdir/test_mapping.in
+++ b/src/testdir/test_mapping.in
@@ -35,7 +35,20 @@ o+
:nnoremap . :call feedkeys(".", "in")<cr>
:/^a b
0qqdw.ifooqj0@q:unmap .
-
+:" langmap doesn't work with multibyte chars, that are mapped
+:set langmap=öS
+:nnoremap S s
+/^MATCH HERE /e
+ö:
+:" langmap needs to allow for recursive mappings issue #297
+:nunmap S
+:set langmap=
+:set langmap=öc
+:nnoremap col :.put ='Resolved langmap and mapping'<cr>
+:/^# TEST 7/
+:" Needs feedkeys, test doesn't work with öol
+:call feedkeys("öol", 't')
+:nunmap S
:/^test/,$w! test.out
:qa!
@@ -43,6 +56,13 @@ ENDTEST
test starts here:
+# TEST 5: let feedkeys insert chars at current position in mapping
a b c d
a b c d
+# TEST 6: Apply mapping to langmapped multibyte char
+MATCH HERE Do not replace.
+
+# TEST 7: Resolved langmaps need to be checked for mappings
+
+
diff --git a/src/testdir/test_mapping.ok b/src/testdir/test_mapping.ok
--- a/src/testdir/test_mapping.ok
+++ b/src/testdir/test_mapping.ok
@@ -1,7 +1,15 @@
test starts here:
+# TEST 5: let feedkeys insert chars at current position in mapping
fooc d
fooc d
+
+# TEST 6: Apply mapping to langmapped multibyte char
+MATCH HERE: Do not replace.
+
+# TEST 7: Resolved langmaps need to be checked for mappings
+Resolved langmap and mapping
+
vim
TEST2: CTRL-C |<ctrl-c>A|