Patch 8.2.1499
Problem:    Vim9: error when using "$" with col().
Solution:   Reorder getting the column value. (closes #6744)
Files:      src/eval.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.1498/src/eval.c  2020-08-20 15:52:13.973371001 +0200
--- src/eval.c  2020-08-20 22:06:02.760258467 +0200
***************
*** 4841,4859 ****
        pos.lnum = list_find_nr(l, 0L, &error);
        if (error || pos.lnum <= 0 || pos.lnum > curbuf->b_ml.ml_line_count)
            return NULL;        // invalid line number
- 
-       // Get the column number
-       pos.col = list_find_nr(l, 1L, &error);
-       if (error)
-           return NULL;
        len = (long)STRLEN(ml_get(pos.lnum));
  
        // We accept "$" for the column number: last column.
        li = list_find(l, 1L);
        if (li != NULL && li->li_tv.v_type == VAR_STRING
                && li->li_tv.vval.v_string != NULL
                && STRCMP(li->li_tv.vval.v_string, "$") == 0)
            pos.col = len + 1;
  
        // Accept a position up to the NUL after the line.
        if (pos.col == 0 || (int)pos.col > len + 1)
--- 4841,4863 ----
        pos.lnum = list_find_nr(l, 0L, &error);
        if (error || pos.lnum <= 0 || pos.lnum > curbuf->b_ml.ml_line_count)
            return NULL;        // invalid line number
        len = (long)STRLEN(ml_get(pos.lnum));
  
+       // Get the column number
        // We accept "$" for the column number: last column.
        li = list_find(l, 1L);
        if (li != NULL && li->li_tv.v_type == VAR_STRING
                && li->li_tv.vval.v_string != NULL
                && STRCMP(li->li_tv.vval.v_string, "$") == 0)
+       {
            pos.col = len + 1;
+       }
+       else
+       {
+           pos.col = list_find_nr(l, 1L, &error);
+           if (error)
+               return NULL;
+       }
  
        // Accept a position up to the NUL after the line.
        if (pos.col == 0 || (int)pos.col > len + 1)
*** ../vim-8.2.1498/src/testdir/test_vim9_func.vim      2020-08-19 
21:20:46.089038670 +0200
--- src/testdir/test_vim9_func.vim      2020-08-20 22:09:07.931391100 +0200
***************
*** 1320,1325 ****
--- 1320,1331 ----
    assert_equal(buf, bufnr('%'))
  enddef
  
+ def Test_col()
+   new
+   setline(1, 'asdf')
+   assert_equal(5, col([1, '$']))
+ enddef
+ 
  def Test_getreg_return_type()
    let s1: string = getreg('"')
    let s2: string = getreg('"', 1)
*** ../vim-8.2.1498/src/version.c       2020-08-20 18:59:02.106779176 +0200
--- src/version.c       2020-08-20 22:10:29.195010165 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1499,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
252. You vote for foreign officials.

 /// 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/202008202030.07KKU1qh294974%40masaka.moolenaar.net.

Raspunde prin e-mail lui