Patch 8.2.3969
Problem:    Value of MAXCOL not available in Vim script.
Solution:   Add v:maxcol. (Naohiro Ono, closes #9451)
Files:      runtime/doc/builtin.txt, runtime/doc/eval.txt, src/evalvars.c,
            src/testdir/test_cursor_func.vim, src/testdir/test_normal.vim,
            src/testdir/test_put.vim, src/vim.h


*** ../vim-8.2.3968/runtime/doc/builtin.txt     2021-12-28 11:24:44.632994386 
+0000
--- runtime/doc/builtin.txt     2022-01-01 14:54:04.520310464 +0000
***************
*** 2480,2486 ****
                        :let l = filter(copy(mylist), 'v:val =~ "KEEP"')
  
  <             Returns {expr1}, the |List| or |Dictionary| that was filtered,
!               or a new |Blob| or |String|. 
                When an error is encountered while evaluating {expr2} no
                further items in {expr1} are processed.
                When {expr2} is a Funcref errors inside a function are ignored,
--- 2480,2486 ----
                        :let l = filter(copy(mylist), 'v:val =~ "KEEP"')
  
  <             Returns {expr1}, the |List| or |Dictionary| that was filtered,
!               or a new |Blob| or |String|.
                When an error is encountered while evaluating {expr2} no
                further items in {expr1} are processed.
                When {expr2} is a Funcref errors inside a function are ignored,
***************
*** 3128,3135 ****
                Get the position for String {expr}. Same as |getpos()| but the
                column number in the returned List is a character index
                instead of a byte index.
!               If |getpos()| returns a very large column number, such as
!               2147483647, then getcharpos() will return the character index
                of the last character.
  
                Example:
--- 3130,3137 ----
                Get the position for String {expr}. Same as |getpos()| but the
                column number in the returned List is a character index
                instead of a byte index.
!               If |getpos()| returns a very large column number, equal to
!               |v:maxcol|, then getcharpos() will return the character index
                of the last character.
  
                Example:
***************
*** 3279,3285 ****
                includes an extra "curswant" item in the list:
                    [0, lnum, col, off, curswant] ~
                The "curswant" number is the preferred column when moving the
!               cursor vertically.  Also see |getcursorcharpos()| and
                |getpos()|.
                The first "bufnum" item is always zero. The byte position of
                the cursor is returned in 'col'. To get the character
--- 3281,3288 ----
                includes an extra "curswant" item in the list:
                    [0, lnum, col, off, curswant] ~
                The "curswant" number is the preferred column when moving the
!               cursor vertically.  After |$| command it will be a very large
!               number equal to |v:maxcol|.  Also see |getcursorcharpos()| and
                |getpos()|.
                The first "bufnum" item is always zero. The byte position of
                the cursor is returned in 'col'. To get the character
***************
*** 3624,3635 ****
                character.
                Note that for '< and '> Visual mode matters: when it is "V"
                (visual line mode) the column of '< is zero and the column of
!               '> is a large number.
                The column number in the returned List is the byte position
                within the line. To get the character position in the line,
                use |getcharpos()|.
!               The column number can be very large, e.g. 2147483647, in which
!               case it means "after the end of the line".
                This can be used to save and restore the position of a mark: >
                        let save_a_mark = getpos("'a")
                        ...
--- 3627,3638 ----
                character.
                Note that for '< and '> Visual mode matters: when it is "V"
                (visual line mode) the column of '< is zero and the column of
!               '> is a large number equal to |v:maxcol|.
                The column number in the returned List is the byte position
                within the line. To get the character position in the line,
                use |getcharpos()|.
!               A very large column number equal to |v:maxcol| can be returned,
!               in which case it means "after the end of the line".
                This can be used to save and restore the position of a mark: >
                        let save_a_mark = getpos("'a")
                        ...
***************
*** 9748,9757 ****
                The return value includes:
                        lnum            cursor line number
                        col             cursor column (Note: the first column
!                                       zero, as opposed to what getpos()
                                        returns)
                        coladd          cursor column offset for 'virtualedit'
!                       curswant        column for vertical movement
                        topline         first line in the window
                        topfill         filler lines, only in diff mode
                        leftcol         first column displayed; only used when
--- 9751,9764 ----
                The return value includes:
                        lnum            cursor line number
                        col             cursor column (Note: the first column
!                                       zero, as opposed to what |getcurpos()|
                                        returns)
                        coladd          cursor column offset for 'virtualedit'
!                       curswant        column for vertical movement (Note:
!                                       the first column is zero, as opposed
!                                       to what |getcurpos()| returns).  After
!                                       |$| command it will be a very large
!                                       number equal to |v:maxcol|.
                        topline         first line in the window
                        topfill         filler lines, only in diff mode
                        leftcol         first column displayed; only used when
*** ../vim-8.2.3968/runtime/doc/eval.txt        2021-12-27 21:26:38.956743275 
+0000
--- runtime/doc/eval.txt        2022-01-01 14:54:04.520310464 +0000
***************
*** 2159,2164 ****
--- 2161,2169 ----
                expressions is being evaluated.  Read-only when in the
                |sandbox|.
  
+                                               *v:maxcol* *maxcol-variable*
+ v:maxcol      Maximum line length.
+ 
                                        *v:mouse_win* *mouse_win-variable*
  v:mouse_win   Window number for a mouse click obtained with |getchar()|.
                First window has number 1, like with |winnr()|.  The value is
*** ../vim-8.2.3968/src/evalvars.c      2022-01-01 14:19:44.036353866 +0000
--- src/evalvars.c      2022-01-01 14:54:04.520310464 +0000
***************
*** 154,159 ****
--- 154,160 ----
      {VV_NAME("sizeofint",      VAR_NUMBER), NULL, VV_RO},
      {VV_NAME("sizeoflong",     VAR_NUMBER), NULL, VV_RO},
      {VV_NAME("sizeofpointer",  VAR_NUMBER), NULL, VV_RO},
+     {VV_NAME("maxcol",                 VAR_NUMBER), NULL, VV_RO},
  };
  
  // shorthand
***************
*** 241,246 ****
--- 242,248 ----
      set_vim_var_nr(VV_SIZEOFINT, sizeof(int));
      set_vim_var_nr(VV_SIZEOFLONG, sizeof(long));
      set_vim_var_nr(VV_SIZEOFPOINTER, sizeof(char *));
+     set_vim_var_nr(VV_MAXCOL, MAXCOL);
  
      set_vim_var_nr(VV_TYPE_NUMBER,  VAR_TYPE_NUMBER);
      set_vim_var_nr(VV_TYPE_STRING,  VAR_TYPE_STRING);
*** ../vim-8.2.3968/src/testdir/test_cursor_func.vim    2021-07-21 
17:04:53.343910544 +0100
--- src/testdir/test_cursor_func.vim    2022-01-01 14:54:04.520310464 +0000
***************
*** 38,43 ****
--- 38,55 ----
    quit!
  endfunc
  
+ func Test_curswant_maxcol()
+   new
+   call setline(1, 'foo')
+ 
+   " Test that after "$" command curswant is set to the same value as v:maxcol.
+   normal! 1G$
+   call assert_equal(v:maxcol, getcurpos()[4])
+   call assert_equal(v:maxcol, winsaveview().curswant)
+ 
+   quit!
+ endfunc
+ 
  " Very short version of what matchparen does.
  function s:Highlight_Matching_Pair()
    let save_cursor = getcurpos()
*** ../vim-8.2.3968/src/testdir/test_normal.vim 2021-12-26 15:00:00.503078780 
+0000
--- src/testdir/test_normal.vim 2022-01-01 14:54:04.520310464 +0000
***************
*** 858,864 ****
    set nostartofline
    exe "norm! $\<c-b>"
    call assert_equal('92', getline('.'))
!   call assert_equal([0, 92, 2, 0, 2147483647], getcurpos())
    " cleanup
    set startofline
    bw!
--- 858,864 ----
    set nostartofline
    exe "norm! $\<c-b>"
    call assert_equal('92', getline('.'))
!   call assert_equal([0, 92, 2, 0, v:maxcol], getcurpos())
    " cleanup
    set startofline
    bw!
***************
*** 902,908 ****
    norm! >>$ztzb
    call assert_equal(' 30', getline('.'))
    call assert_equal(30, winsaveview()['topline']+winheight(0)-1)
!   call assert_equal([0, 30, 3, 0, 2147483647], getcurpos())
  
    " Test for z-
    1
--- 902,908 ----
    norm! >>$ztzb
    call assert_equal(' 30', getline('.'))
    call assert_equal(30, winsaveview()['topline']+winheight(0)-1)
!   call assert_equal([0, 30, 3, 0, v:maxcol], getcurpos())
  
    " Test for z-
    1
***************
*** 2798,2804 ****
    call assert_equal([0, 14, 1, 0, 1], getcurpos())
    " count > buffer content
    norm! 120go
!   call assert_equal([0, 14, 1, 0, 2147483647], getcurpos())
    " clean up
    bw!
  endfunc
--- 2798,2804 ----
    call assert_equal([0, 14, 1, 0, 1], getcurpos())
    " count > buffer content
    norm! 120go
!   call assert_equal([0, 14, 1, 0, v:maxcol], getcurpos())
    " clean up
    bw!
  endfunc
***************
*** 2980,2986 ****
    set nostartofline
    exe "norm! $\<c-u>"
    call assert_equal('95', getline('.'))
!   call assert_equal([0, 95, 2, 0, 2147483647], getcurpos())
    " cleanup
    set startofline
    bw!
--- 2980,2986 ----
    set nostartofline
    exe "norm! $\<c-u>"
    call assert_equal('95', getline('.'))
!   call assert_equal([0, 95, 2, 0, v:maxcol], getcurpos())
    " cleanup
    set startofline
    bw!
*** ../vim-8.2.3968/src/testdir/test_put.vim    2021-11-25 19:31:11.415905063 
+0000
--- src/testdir/test_put.vim    2022-01-01 14:54:04.520310464 +0000
***************
*** 205,211 ****
    call assert_equal([0, 1, 7, 0], getpos("']"))
  
    normal Vyp
!   call assert_equal([0, 1, 2147483647, 0], getpos("'>"))
    call assert_equal([0, 2, 7, 0], getpos("']"))
    bwipe!
  endfunc
--- 205,211 ----
    call assert_equal([0, 1, 7, 0], getpos("']"))
  
    normal Vyp
!   call assert_equal([0, 1, v:maxcol, 0], getpos("'>"))
    call assert_equal([0, 2, 7, 0], getpos("']"))
    bwipe!
  endfunc
*** ../vim-8.2.3968/src/vim.h   2021-12-28 15:51:40.079738196 +0000
--- src/vim.h   2022-01-01 14:54:04.520310464 +0000
***************
*** 2067,2073 ****
  #define VV_SIZEOFINT  100
  #define VV_SIZEOFLONG 101
  #define VV_SIZEOFPOINTER 102
! #define VV_LEN                103     // number of v: vars
  
  // used for v_number in VAR_BOOL and VAR_SPECIAL
  #define VVAL_FALSE    0L      // VAR_BOOL
--- 2067,2074 ----
  #define VV_SIZEOFINT  100
  #define VV_SIZEOFLONG 101
  #define VV_SIZEOFPOINTER 102
! #define VV_MAXCOL     103
! #define VV_LEN                104     // number of v: vars
  
  // used for v_number in VAR_BOOL and VAR_SPECIAL
  #define VVAL_FALSE    0L      // VAR_BOOL
*** ../vim-8.2.3968/src/version.c       2022-01-01 14:25:52.315548310 +0000
--- src/version.c       2022-01-01 14:56:10.624075121 +0000
***************
*** 751,752 ****
--- 751,754 ----
  {   /* Add new patch number below this line */
+ /**/
+     3969,
  /**/

-- 
If Microsoft would build a car...
... The airbag system would ask "are you SURE?" before deploying.

 /// 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/20220101150000.B47F91C0A5B%40moolenaar.net.

Raspunde prin e-mail lui