comparison src/evalfunc.c @ 25527:d5e9c05b4811 v8.2.3300

patch 8.2.3300: Lua: can only execute on Vim command at a time Commit: https://github.com/vim/vim/commit/11328bc7df0ecc47f4025a10bb86882a659e9994 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Fri Aug 6 21:34:38 2021 +0200 patch 8.2.3300: Lua: can only execute on Vim command at a time Problem: Lua: can only execute on Vim command at a time. Not easy to get the Vim version. Solution: Make vim.command() accept multiple lines. Add vim.version(). (Yegappan Lakshmanan, closes #8716)
author Bram Moolenaar <Bram@vim.org>
date Fri, 06 Aug 2021 21:45:05 +0200
parents 8880eb140a00
children 446f478d6fb1
comparison
equal deleted inserted replaced
25526:f9ebb5b05597 25527:d5e9c05b4811
3363 redir_execute_ga.ga_len += len; 3363 redir_execute_ga.ga_len += len;
3364 } 3364 }
3365 } 3365 }
3366 3366
3367 /* 3367 /*
3368 * Get next line from a string containing NL separated lines.
3369 * Called by do_cmdline() to get the next line.
3370 * Returns an allocated string, or NULL when at the end of the string.
3371 */
3372 static char_u *
3373 get_str_line(
3374 int c UNUSED,
3375 void *cookie,
3376 int indent UNUSED,
3377 getline_opt_T options UNUSED)
3378 {
3379 char_u *start = *(char_u **)cookie;
3380 char_u *line;
3381 char_u *p;
3382
3383 p = start;
3384 if (p == NULL || *p == NUL)
3385 return NULL;
3386 p = vim_strchr(p, '\n');
3387 if (p == NULL)
3388 line = vim_strsave(start);
3389 else
3390 {
3391 line = vim_strnsave(start, p - start);
3392 p++;
3393 }
3394
3395 *(char_u **)cookie = p;
3396 return line;
3397 }
3398
3399 /*
3400 * Execute a series of Ex commands in 'str'
3401 */
3402 void
3403 execute_cmds_from_string(char_u *str)
3404 {
3405 do_cmdline(NULL, get_str_line, (void *)&str,
3406 DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT|DOCMD_KEYTYPED);
3407 }
3408
3409 /*
3368 * Get next line from a list. 3410 * Get next line from a list.
3369 * Called by do_cmdline() to get the next line. 3411 * Called by do_cmdline() to get the next line.
3370 * Returns allocated string, or NULL for end of function. 3412 * Returns allocated string, or NULL for end of function.
3371 */ 3413 */
3372 static char_u * 3414 static char_u *