Patch 8.2.0963
Problem:    Number increment/decrement does not work with 'virtualedit'.
Solution:   Handle coladd changing. (Christian Brabandt, closes #6240,
            closes #923)
Files:      runtime/doc/options.txt, runtime/doc/various.txt, src/ops.c,
            src/testdir/test_increment.vim


*** ../vim-8.2.0962/runtime/doc/options.txt     2020-06-10 21:46:56.383670037 
+0200
--- runtime/doc/options.txt     2020-06-12 20:14:36.013701572 +0200
***************
*** 8558,8565 ****
                                            *'virtualedit'* *'ve'*
  'virtualedit' 've'    string  (default "")
                        global
-                       {not available when compiled without the
-                       |+virtualedit| feature}
        A comma separated list of these words:
            block       Allow virtual editing in Visual block mode.
            insert      Allow virtual editing in Insert mode.
--- 8556,8561 ----
*** ../vim-8.2.0962/runtime/doc/various.txt     2020-04-12 17:52:49.421492420 
+0200
--- runtime/doc/various.txt     2020-06-12 20:14:36.013701572 +0200
***************
*** 463,469 ****
  N  *+viminfo*         |'viminfo'|
     *+vertsplit*               Vertically split windows |:vsplit|; Always 
enabled
                        since 8.0.1118.
! N  *+virtualedit*     |'virtualedit'|
  T  *+visual*          Visual mode |Visual-mode| Always enabled since 7.4.200.
  T  *+visualextra*     extra Visual mode commands |blockwise-operators|
  T  *+vreplace*                |gR| and |gr|
--- 470,476 ----
  N  *+viminfo*         |'viminfo'|
     *+vertsplit*               Vertically split windows |:vsplit|; Always 
enabled
                        since 8.0.1118.
! N  *+virtualedit*     |'virtualedit'| Always enabled since 8.1.826.
  T  *+visual*          Visual mode |Visual-mode| Always enabled since 7.4.200.
  T  *+visualextra*     extra Visual mode commands |blockwise-operators|
  T  *+vreplace*                |gR| and |gr|
*** ../vim-8.2.0962/src/ops.c   2020-06-04 18:21:56.046395485 +0200
--- src/ops.c   2020-06-12 20:18:23.928816491 +0200
***************
*** 2446,2451 ****
--- 2446,2452 ----
      int               maxlen = 0;
      pos_T     startpos;
      pos_T     endpos;
+     colnr_T   save_coladd = 0;
  
      do_hex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL);       // "heX"
      do_oct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL);       // "Octal"
***************
*** 2453,2463 ****
      do_alpha = (vim_strchr(curbuf->b_p_nf, 'p') != NULL);     // "alPha"
      do_unsigned = (vim_strchr(curbuf->b_p_nf, 'u') != NULL);  // "Unsigned"
  
      curwin->w_cursor = *pos;
      ptr = ml_get(pos->lnum);
      col = pos->col;
  
!     if (*ptr == NUL)
        goto theend;
  
      /*
--- 2454,2470 ----
      do_alpha = (vim_strchr(curbuf->b_p_nf, 'p') != NULL);     // "alPha"
      do_unsigned = (vim_strchr(curbuf->b_p_nf, 'u') != NULL);  // "Unsigned"
  
+     if (virtual_active())
+     {
+       save_coladd = pos->coladd;
+       pos->coladd = 0;
+     }
+ 
      curwin->w_cursor = *pos;
      ptr = ml_get(pos->lnum);
      col = pos->col;
  
!     if (*ptr == NUL || col + !!save_coladd >= (int)STRLEN(ptr))
        goto theend;
  
      /*
***************
*** 2824,2829 ****
--- 2831,2838 ----
        curwin->w_cursor = save_cursor;
      else if (did_change)
        curwin->w_set_curswant = TRUE;
+     else if (virtual_active())
+       curwin->w_cursor.coladd = save_coladd;
  
      return did_change;
  }
*** ../vim-8.2.0962/src/testdir/test_increment.vim      2020-05-31 
15:08:55.118721233 +0200
--- src/testdir/test_increment.vim      2020-06-12 20:14:36.013701572 +0200
***************
*** 840,843 ****
--- 840,879 ----
    set nrformats-=unsigned
  endfunc
  
+ func Test_normal_increment_with_virtualedit()
+   set virtualedit=all
+ 
+   call setline(1, ["\<TAB>1"])
+   exec "norm! 0\<C-A>"
+   call assert_equal("\<TAB>2", getline(1))
+   call assert_equal([0, 1, 2, 0], getpos('.'))
+ 
+   call setline(1, ["\<TAB>1"])
+   exec "norm! 0l\<C-A>"
+   call assert_equal("\<TAB>2", getline(1))
+   call assert_equal([0, 1, 2, 0], getpos('.'))
+ 
+   call setline(1, ["\<TAB>1"])
+   exec "norm! 07l\<C-A>"
+   call assert_equal("\<TAB>2", getline(1))
+   call assert_equal([0, 1, 2, 0], getpos('.'))
+ 
+   call setline(1, ["\<TAB>1"])
+   exec "norm! 0w\<C-A>"
+   call assert_equal("\<TAB>2", getline(1))
+   call assert_equal([0, 1, 2, 0], getpos('.'))
+ 
+   call setline(1, ["\<TAB>1"])
+   exec "norm! 0wl\<C-A>"
+   call assert_equal("\<TAB>1", getline(1))
+   call assert_equal([0, 1, 3, 0], getpos('.'))
+ 
+   call setline(1, ["\<TAB>1"])
+   exec "norm! 0w30l\<C-A>"
+   call assert_equal("\<TAB>1", getline(1))
+   call assert_equal([0, 1, 3, 29], getpos('.'))
+ 
+   set virtualedit&
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0962/src/version.c       2020-06-12 20:11:49.802336659 +0200
--- src/version.c       2020-06-12 20:16:49.713184058 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     963,
  /**/

-- 
Shit makes the flowers grow and that's beautiful

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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/202006121820.05CIK9jW387194%40masaka.moolenaar.net.

Raspunde prin e-mail lui