diff src/eval.c @ 21899:8fe86125dcba v8.2.1499

patch 8.2.1499: Vim9: error when using "$" with col() Commit: https://github.com/vim/vim/commit/ec65d77fa26cc87f7ce54a5a941a799e3a667c50 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Aug 20 22:29:12 2020 +0200 patch 8.2.1499: Vim9: error when using "$" with col() Problem: Vim9: error when using "$" with col(). Solution: Reorder getting the column value. (closes https://github.com/vim/vim/issues/6744)
author Bram Moolenaar <Bram@vim.org>
date Thu, 20 Aug 2020 22:30:04 +0200
parents e7e485a60caf
children 2559dc02bd64
line wrap: on
line diff
--- 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
+	len = (long)STRLEN(ml_get(pos.lnum));
 
 	// 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;
+	}
+	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)