comparison 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
comparison
equal deleted inserted replaced
20058:bc03e6cae236 20059:de756b3f4dee
1833 /* 1833 /*
1834 * If we got a line, but no command, then go to the line. 1834 * If we got a line, but no command, then go to the line.
1835 * If we find a '|' or '\n' we set ea.nextcmd. 1835 * If we find a '|' or '\n' we set ea.nextcmd.
1836 */ 1836 */
1837 if (*ea.cmd == NUL || *ea.cmd == '"' 1837 if (*ea.cmd == NUL || *ea.cmd == '"'
1838 || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL) 1838 #ifdef FEAT_EVAL
1839 || (*ea.cmd == '#' && !starts_with_colon && in_vim9script())
1840 #endif
1841 || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL)
1839 { 1842 {
1840 /* 1843 /*
1841 * strange vi behaviour: 1844 * strange vi behaviour:
1842 * ":3" jumps to line 3 1845 * ":3" jumps to line 3
1843 * ":3|..." prints line 3 1846 * ":3|..." prints line 3
4759 goto_buffer(eap, DOBUF_LAST, BACKWARD, 0); 4762 goto_buffer(eap, DOBUF_LAST, BACKWARD, 0);
4760 if (eap->do_ecmd_cmd != NULL) 4763 if (eap->do_ecmd_cmd != NULL)
4761 do_cmdline_cmd(eap->do_ecmd_cmd); 4764 do_cmdline_cmd(eap->do_ecmd_cmd);
4762 } 4765 }
4763 4766
4767 /*
4768 * Check if "c" ends an Ex command.
4769 * In Vim9 script does not check for white space before #.
4770 */
4764 int 4771 int
4765 ends_excmd(int c) 4772 ends_excmd(int c)
4766 { 4773 {
4767 #ifdef FEAT_EVAL 4774 #ifdef FEAT_EVAL
4768 if (c == '#') 4775 if (c == '#')
4769 // TODO: should check for preceding white space 4776 return in_vim9script();
4777 #endif
4778 return (c == NUL || c == '|' || c == '"' || c == '\n');
4779 }
4780
4781 /*
4782 * Like ends_excmd() but checks that a # in Vim9 script either has "cmd" equal
4783 * to "cmd_start" or has a white space character before it.
4784 */
4785 int
4786 ends_excmd2(char_u *cmd_start, char_u *cmd)
4787 {
4788 int c = *cmd;
4789
4790 #ifdef FEAT_EVAL
4791 if (c == '#' && (cmd == cmd_start || VIM_ISWHITE(cmd[-1])))
4770 return in_vim9script(); 4792 return in_vim9script();
4771 #endif 4793 #endif
4772 return (c == NUL || c == '|' || c == '"' || c == '\n'); 4794 return (c == NUL || c == '|' || c == '"' || c == '\n');
4773 } 4795 }
4774 4796