Patch 9.0.0806
Problem:    'langmap' works differently when there are modifiers.
Solution:   Only apply 'langmap' to a character where modifiers have no
            effect. (closes #11395, closes #11404)
Files:      src/getchar.c, src/testdir/test_langmap.vim


*** ../vim-9.0.0805/src/getchar.c       2022-10-20 13:11:12.234206115 +0100
--- src/getchar.c       2022-10-20 17:58:04.750440381 +0100
***************
*** 2590,2613 ****
            {
  #ifdef FEAT_LANGMAP
                int     nomap = nolmaplen;
!               int     c2;
  #endif
                // find the match length of this mapping
                for (mlen = 1; mlen < typebuf.tb_len; ++mlen)
                {
  #ifdef FEAT_LANGMAP
-                   c2 = typebuf.tb_buf[typebuf.tb_off + mlen];
                    if (nomap > 0)
                        --nomap;
!                   else if (c2 == K_SPECIAL)
!                       nomap = 2;
                    else
!                       LANGMAP_ADJUST(c2, TRUE);
!                   if (mp->m_keys[mlen] != c2)
! #else
!                   if (mp->m_keys[mlen] !=
!                                        typebuf.tb_buf[typebuf.tb_off + mlen])
  #endif
                        break;
                }
  
--- 2590,2624 ----
            {
  #ifdef FEAT_LANGMAP
                int     nomap = nolmaplen;
!               int     modifiers = 0;
  #endif
                // find the match length of this mapping
                for (mlen = 1; mlen < typebuf.tb_len; ++mlen)
                {
+                   int c2 = typebuf.tb_buf[typebuf.tb_off + mlen];
  #ifdef FEAT_LANGMAP
                    if (nomap > 0)
+                   {
+                       if (nomap == 2 && c2 == KS_MODIFIER)
+                           modifiers = 1;
+                       else if (nomap == 1 && modifiers == 1)
+                           modifiers = c2;
                        --nomap;
!                   }
                    else
!                   {
!                       if (c2 == K_SPECIAL)
!                           nomap = 2;
!                       else if (merge_modifyOtherKeys(c2, &modifiers) == c2)
!                           // Only apply 'langmap' if merging modifiers into
!                           // the key will not result in another character,
!                           // so that 'langmap' behaves consistently in
!                           // different terminals and GUIs.
!                           LANGMAP_ADJUST(c2, TRUE);
!                       modifiers = 0;
!                   }
  #endif
+                   if (mp->m_keys[mlen] != c2)
                        break;
                }
  
*** ../vim-9.0.0805/src/testdir/test_langmap.vim        2020-08-12 
17:43:41.000000000 +0100
--- src/testdir/test_langmap.vim        2022-10-20 17:27:08.148795787 +0100
***************
*** 49,54 ****
--- 49,87 ----
    call feedkeys(';', 'tx')
    call assert_equal(5, col('.'))
  
+   set langmap=RL
+   let g:counter = 0
+   nnoremap L;L <Cmd>let g:counter += 1<CR>
+   nnoremap <C-L> <Cmd>throw 'This mapping shoud not be triggered'<CR>
+ 
+   " 'langmap' is applied to keys without modifiers when matching a mapping
+   call feedkeys('R;R', 'tx')
+   call assert_equal(1, g:counter)
+   nunmap L;L
+   unlet g:counter
+ 
+   delete
+   call assert_equal('', getline(1))
+   undo
+   call assert_equal('Hello World', getline(1))
+   " 'langmap' does not change Ctrl-R to Ctrl-L for consistency
+   call feedkeys("\<*C-R>", 'tx')
+   call assert_equal('', getline(1))
+ 
+   set langmap=6L
+   undo
+   setlocal bufhidden=hide
+   let oldbuf = bufnr()
+   enew
+   call assert_notequal(oldbuf, bufnr())
+   " 'langmap' does not change Ctrl-6 to Ctrl-L for consistency
+   " Ctrl-6 becomes Ctrl-^ after merging the Ctrl modifier
+   call feedkeys("\<*C-6>", 'tx')
+   call assert_equal(oldbuf, bufnr())
+   setlocal bufhidden&
+ 
+   nunmap <C-L>
+ 
    set langmap&
    quit!
  endfunc
*** ../vim-9.0.0805/src/version.c       2022-10-20 16:03:29.486536722 +0100
--- src/version.c       2022-10-20 17:28:53.749739059 +0100
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     806,
  /**/

-- 
A M00se once bit my sister ...
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20221020170003.DE0A91C17E4%40moolenaar.net.

Raspunde prin e-mail lui