Patch 8.2.3265
Problem:    Smartcase does not work correctly in very magic pattern.
Solution:   Take the magicness into account when skipping over regexp items.
            (Christian Brabandt, closes #8682, closes #7845)
Files:      src/search.c, src/testdir/test_search.vim


*** ../vim-8.2.3264/src/search.c        2021-07-31 13:31:37.327213783 +0200
--- src/search.c        2021-08-01 12:42:54.848836669 +0200
***************
*** 430,435 ****
--- 430,439 ----
  pat_has_uppercase(char_u *pat)
  {
      char_u *p = pat;
+     magic_T magic_val = MAGIC_ON;
+ 
+     // get the magicness of the pattern
+     (void)skip_regexp_ex(pat, NUL, magic_isset(), NULL, NULL, &magic_val);
  
      while (*p != NUL)
      {
***************
*** 441,447 ****
                return TRUE;
            p += l;
        }
!       else if (*p == '\\')
        {
            if (p[1] == '_' && p[2] != NUL)  // skip "\_X"
                p += 3;
--- 445,451 ----
                return TRUE;
            p += l;
        }
!       else if (*p == '\\' && magic_val == MAGIC_ON)
        {
            if (p[1] == '_' && p[2] != NUL)  // skip "\_X"
                p += 3;
***************
*** 452,457 ****
--- 456,466 ----
            else
                p += 1;
        }
+       else if ((*p == '%' || *p == '_') && magic_val == MAGIC_ALL)
+       {
+           if (p[1] != NUL)  // skip "_X" and %X
+               p += 2;
+       }
        else if (MB_ISUPPER(*p))
            return TRUE;
        else
*** ../vim-8.2.3264/src/testdir/test_search.vim 2021-07-10 13:15:35.295053013 
+0200
--- src/testdir/test_search.vim 2021-08-01 12:39:13.285508277 +0200
***************
*** 1912,1915 ****
--- 1912,1969 ----
    call delete('Xis_subst_script2')
  endfunc
  
+ func Test_pattern_is_uppercase_smartcase()
+   new
+   let input=['abc', 'ABC', 'Abc', 'abC']
+   call setline(1, input)
+   call cursor(1,1)
+   " default, matches firstline
+   %s/abc//g
+   call assert_equal(['', 'ABC', 'Abc', 'abC'],
+         \ getline(1, '$'))
+ 
+   set smartcase ignorecase
+   sil %d
+   call setline(1, input)
+   call cursor(1,1)
+   " with smartcase and incsearch set, matches everything
+   %s/abc//g
+   call assert_equal(['', '', '', ''], getline(1, '$'))
+ 
+   sil %d
+   call setline(1, input)
+   call cursor(1,1)
+   " with smartcase and incsearch set and found an uppercase letter,
+   " match only that.
+   %s/abC//g
+   call assert_equal(['abc', 'ABC', 'Abc', ''],
+         \ getline(1, '$'))
+ 
+   sil %d
+   call setline(1, input)
+   call cursor(1,1)
+   exe "norm! vG$\<esc>"
+   " \%V should not be detected as uppercase letter
+   %s/\%Vabc//g
+   call assert_equal(['', '', '', ''], getline(1, '$'))
+ 
+   call setline(1, input)
+   call cursor(1,1)
+   exe "norm! vG$\<esc>"
+   " \v%V should not be detected as uppercase letter
+   %s/\v%Vabc//g
+   call assert_equal(['', '', '', ''], getline(1, '$'))
+ 
+   call setline(1, input)
+   call cursor(1,1)
+   exe "norm! vG$\<esc>"
+   " \v%VabC should be detected as uppercase letter
+   %s/\v%VabC//g
+   call assert_equal(['abc', 'ABC', 'Abc', ''],
+         \ getline(1, '$'))
+ 
+   set smartcase& ignorecase&
+   bw!
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.3264/src/version.c       2021-08-01 12:01:45.936414564 +0200
--- src/version.c       2021-08-01 12:44:08.940612099 +0200
***************
*** 757,758 ****
--- 757,760 ----
  {   /* Add new patch number below this line */
+ /**/
+     3265,
  /**/

-- 
The psychic said, "God bless you."  I said, "I didn't sneeze."  She
looked deep into my eyes and said, "You will, eventually."  And, damn
if she wasn't right.  Two days later, I sneezed.  --Ellen Degeneres

 /// 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/202108011045.171AjDGi222606%40masaka.moolenaar.net.

Raspunde prin e-mail lui