comparison src/eval.c @ 22580:eb54d34ecd27 v8.2.1838

patch 8.2.1838: Vim9: cannot insert a comment line in an expression Commit: https://github.com/vim/vim/commit/93be1644db2848659b0610477968c83f53619da1 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 11 21:34:41 2020 +0200 patch 8.2.1838: Vim9: cannot insert a comment line in an expression Problem: Vim9: cannot insert a comment line in an expression. Solution: Skip comment lines at the script level. (closes https://github.com/vim/vim/issues/7111)
author Bram Moolenaar <Bram@vim.org>
date Sun, 11 Oct 2020 21:45:03 +0200
parents 7d6ba4204f66
children 336ac63fb987
comparison
equal deleted inserted replaced
22579:837d354b2c0b 22580:eb54d34ecd27
1966 } 1966 }
1967 return ret; 1967 return ret;
1968 } 1968 }
1969 1969
1970 /* 1970 /*
1971 * Get the next line source line without advancing. But do skip over comment
1972 * lines.
1973 */
1974 static char_u *
1975 getline_peek_skip_comments(evalarg_T *evalarg)
1976 {
1977 for (;;)
1978 {
1979 char_u *next = getline_peek(evalarg->eval_getline,
1980 evalarg->eval_cookie);
1981 char_u *p;
1982
1983 if (next == NULL)
1984 break;
1985 p = skipwhite(next);
1986 if (*p != NUL && !vim9_comment_start(p))
1987 return next;
1988 (void)eval_next_line(evalarg);
1989 }
1990 return NULL;
1991 }
1992
1993 /*
1971 * If inside Vim9 script, "arg" points to the end of a line (ignoring a # 1994 * If inside Vim9 script, "arg" points to the end of a line (ignoring a #
1972 * comment) and there is a next line, return the next line (skipping blanks) 1995 * comment) and there is a next line, return the next line (skipping blanks)
1973 * and set "getnext". 1996 * and set "getnext".
1974 * Otherwise just return "arg" unmodified and set "getnext" to FALSE. 1997 * Otherwise just return "arg" unmodified and set "getnext" to FALSE.
1975 * "arg" must point somewhere inside a line, not at the start. 1998 * "arg" must point somewhere inside a line, not at the start.
1986 && (*p == NUL || (VIM_ISWHITE(p[-1]) && vim9_comment_start(p)))) 2009 && (*p == NUL || (VIM_ISWHITE(p[-1]) && vim9_comment_start(p))))
1987 { 2010 {
1988 char_u *next; 2011 char_u *next;
1989 2012
1990 if (evalarg->eval_cookie != NULL) 2013 if (evalarg->eval_cookie != NULL)
1991 next = getline_peek(evalarg->eval_getline, evalarg->eval_cookie); 2014 next = getline_peek_skip_comments(evalarg);
1992 else 2015 else
1993 next = peek_next_line_from_context(evalarg->eval_cctx); 2016 next = peek_next_line_from_context(evalarg->eval_cctx);
1994 2017
1995 if (next != NULL) 2018 if (next != NULL)
1996 { 2019 {