summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-08-20 22:29:12 +0200
committerBram Moolenaar <Bram@vim.org>2020-08-20 22:29:12 +0200
commitec65d77fa26cc87f7ce54a5a941a799e3a667c50 (patch)
tree85d312ddb71ac795c1e1f97304e1408589b16de6
parent733d259a83bfdd3e1670cc1665e1bd56501799df (diff)
patch 8.2.1499: Vim9: error when using "$" with col()v8.2.1499
Problem: Vim9: error when using "$" with col(). Solution: Reorder getting the column value. (closes #6744)
-rw-r--r--src/eval.c14
-rw-r--r--src/testdir/test_vim9_func.vim6
-rw-r--r--src/version.c2
3 files changed, 17 insertions, 5 deletions
diff --git a/src/eval.c b/src/eval.c
index 741599bbf8..cc044a4bd7 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -4841,19 +4841,23 @@ var2fpos(
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));
+ // 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)
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 1f0fd1c8a3..4661108815 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -1320,6 +1320,12 @@ def Test_bufnr()
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)
diff --git a/src/version.c b/src/version.c
index 51306efa16..d1c75a385f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1499,
+/**/
1498,
/**/
1497,