Mercurial > vim
diff src/ex_docmd.c @ 20059:de756b3f4dee v8.2.0585
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Commit: https://github.com/vim/vim/commit/7a09224583b2ad0d9d0648b53cc2d989d45ae96e
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Apr 16 22:10:49 2020 +0200
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Problem: Vim9: # comment not recognized after :vim9script.
Solution: Check script type. Make comment after ":echo" work. And in
several other places.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 16 Apr 2020 22:15:04 +0200 |
parents | 23a4aef4f923 |
children | cc146cde0b4d |
line wrap: on
line diff
--- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -1835,7 +1835,10 @@ do_one_cmd( * If we find a '|' or '\n' we set ea.nextcmd. */ if (*ea.cmd == NUL || *ea.cmd == '"' - || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL) +#ifdef FEAT_EVAL + || (*ea.cmd == '#' && !starts_with_colon && in_vim9script()) +#endif + || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL) { /* * strange vi behaviour: @@ -4761,12 +4764,31 @@ ex_blast(exarg_T *eap) do_cmdline_cmd(eap->do_ecmd_cmd); } +/* + * Check if "c" ends an Ex command. + * In Vim9 script does not check for white space before #. + */ int ends_excmd(int c) { #ifdef FEAT_EVAL if (c == '#') - // TODO: should check for preceding white space + return in_vim9script(); +#endif + return (c == NUL || c == '|' || c == '"' || c == '\n'); +} + +/* + * Like ends_excmd() but checks that a # in Vim9 script either has "cmd" equal + * to "cmd_start" or has a white space character before it. + */ + int +ends_excmd2(char_u *cmd_start, char_u *cmd) +{ + int c = *cmd; + +#ifdef FEAT_EVAL + if (c == '#' && (cmd == cmd_start || VIM_ISWHITE(cmd[-1]))) return in_vim9script(); #endif return (c == NUL || c == '|' || c == '"' || c == '\n');