Updated patch for 7.4.796 attached (Patch 7.4.773 made this patch fail to apply cleanly).
Best, Christian -- Wer im Steinhaus sitzt, sollte nicht mit Gläsern werfen! -- -- 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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Fix various problems with langmap and mapped keys: 1) :set langmap=ö/,a/ :nnoremap / ? Press a in noremal mode, will be resolved to ? Press ö in normal mode, should be resolved to ? 2) :set langmap=öc :nnoremap col :set list!<cr> Press öol should switch list mode (issue #297) This patch does this, by after langmapping the received byte, check, if it is a multibyte char and if it is, check for mappings. # HG changeset patch # Parent 8594ddd6e628c478f0c061a0221aef3fb8d48b1f diff --git a/src/getchar.c b/src/getchar.c --- a/src/getchar.c +++ b/src/getchar.c @@ -1998,6 +1998,7 @@ vgetorpeek(advance) #endif int old_wcol, old_wrow; int wait_tb_len; + int keylen_mb_off = 0; /* keylen adjustment for multibyte chars */ /* * This function doesn't work very well when called recursively. This may @@ -2141,15 +2142,53 @@ vgetorpeek(advance) ) { #ifdef FEAT_LANGMAP + int k = 1; + if (c1 == K_SPECIAL) nolmaplen = 2; else { +#ifdef FEAT_MBYTE + char_u buf[MB_MAXBYTES + 1]; + int j; + + if (has_mbyte && (k = MB_BYTE2LEN_CHECK(c1)) > 1) + { + if (typebuf.tb_len == 1) + { + /* get some more chars */ + j = inchar(typebuf.tb_buf + typebuf.tb_off + typebuf.tb_len, + typebuf.tb_buflen - typebuf.tb_off - typebuf.tb_len - 1, + 0, typebuf.tb_change_cnt); + typebuf.tb_len += j; + } + + if (typebuf.tb_len > 1) + { + buf[0] = c1; + for (j=1; j < k; ++j) + buf[j] = typebuf.tb_buf[typebuf.tb_off + j]; + } + /* need to remember, that we have to remove more bytes */ + keylen_mb_off = k - 1; + k = c1; + c1 = (*mb_ptr2char)(buf); + } +#endif LANGMAP_ADJUST(c1, (State & (CMDLINE | INSERT)) == 0); + if (c1 == k) + keylen_mb_off = 0; nolmaplen = 0; } #endif +#ifdef FEAT_LANGMAP + if (MAP_HASH(local_State, c1) > 255) + { + c1 = k; + keylen_mb_off = 0; + } +#endif #ifdef FEAT_LOCALMAP /* First try buffer-local mappings. */ mp = curbuf->b_maphash[MAP_HASH(local_State, c1)]; @@ -2193,7 +2232,7 @@ vgetorpeek(advance) int c2; #endif /* find the match length of this mapping */ - for (mlen = 1; mlen < typebuf.tb_len; ++mlen) + for (mlen = 1 + keylen_mb_off; mlen < typebuf.tb_len; ++mlen) { #ifdef FEAT_LANGMAP c2 = typebuf.tb_buf[typebuf.tb_off + mlen]; @@ -2203,7 +2242,7 @@ vgetorpeek(advance) nomap = 2; else LANGMAP_ADJUST(c2, TRUE); - if (mp->m_keys[mlen] != c2) + if (mp->m_keys[mlen - keylen_mb_off] != c2) #else if (mp->m_keys[mlen] != typebuf.tb_buf[typebuf.tb_off + mlen]) @@ -2230,8 +2269,8 @@ vgetorpeek(advance) * - Full match: mlen == keylen * - Partly match: mlen == typebuf.tb_len */ - keylen = mp->m_keylen; - if (mlen == keylen + keylen = mp->m_keylen + keylen_mb_off; + if (mlen == keylen || (mlen == typebuf.tb_len && typebuf.tb_len < keylen)) { 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 @@ -44,7 +44,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! @@ -52,6 +65,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|