Mercurial > vim
comparison src/scriptfile.c @ 31596:394967126db9 v9.0.1130
patch 9.0.1130: unexpected output when autoloading a script
Commit: https://github.com/vim/vim/commit/39c82ea6563f8467b8d36f0ecb8ba93a0685c280
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 2 13:08:01 2023 +0000
patch 9.0.1130: unexpected output when autoloading a script
Problem: Unexpected output when autoloading a script for an interactive
operation.
Solution: Reset "KeyTyped" while loading a script and when handling a nested
function. (closes #11773)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 02 Jan 2023 14:15:05 +0100 |
parents | 360f286b5869 |
children | f7fbe6aa92cd |
comparison
equal
deleted
inserted
replaced
31595:209965683b34 | 31596:394967126db9 |
---|---|
1332 /* | 1332 /* |
1333 * Read the file "fname" and execute its lines as EX commands. | 1333 * Read the file "fname" and execute its lines as EX commands. |
1334 * When "ret_sid" is not NULL and we loaded the script before, don't load it | 1334 * When "ret_sid" is not NULL and we loaded the script before, don't load it |
1335 * again. | 1335 * again. |
1336 * | 1336 * |
1337 * The 'eap' argument is used when sourcing lines from a buffer instead of a | 1337 * The "eap" argument is used when sourcing lines from a buffer instead of a |
1338 * file. | 1338 * file. |
1339 * | 1339 * |
1340 * If 'clearvars' is TRUE, then for scripts which are loaded more than | 1340 * If "clearvars" is TRUE, then for scripts which are loaded more than |
1341 * once, clear all the functions and variables previously defined in that | 1341 * once, clear all the functions and variables previously defined in that |
1342 * script. | 1342 * script. |
1343 * | 1343 * |
1344 * This function may be called recursively! | 1344 * This function may be called recursively! |
1345 * | 1345 * |
1536 // When the ":vim9cmd" command modifier is used, source the script as a | 1536 // When the ":vim9cmd" command modifier is used, source the script as a |
1537 // Vim9 script. | 1537 // Vim9 script. |
1538 current_sctx.sc_version = SCRIPT_VERSION_VIM9; | 1538 current_sctx.sc_version = SCRIPT_VERSION_VIM9; |
1539 else | 1539 else |
1540 current_sctx.sc_version = 1; // default script version | 1540 current_sctx.sc_version = 1; // default script version |
1541 current_sctx.sc_lnum = 0; | |
1541 | 1542 |
1542 #ifdef FEAT_EVAL | 1543 #ifdef FEAT_EVAL |
1543 # ifdef FEAT_PROFILE | 1544 # ifdef FEAT_PROFILE |
1544 if (do_profiling == PROF_YES) | 1545 if (do_profiling == PROF_YES) |
1545 prof_child_enter(&wait_start); // entering a child now | 1546 prof_child_enter(&wait_start); // entering a child now |
1547 | 1548 |
1548 // Don't use local function variables, if called from a function. | 1549 // Don't use local function variables, if called from a function. |
1549 // Also starts profiling timer for nested script. | 1550 // Also starts profiling timer for nested script. |
1550 save_funccal(&funccalp_entry); | 1551 save_funccal(&funccalp_entry); |
1551 | 1552 |
1552 current_sctx.sc_lnum = 0; | 1553 // Reset "KeyTyped" to avoid some commands thinking they are invoked |
1554 // interactively. E.g. defining a function would output indent. | |
1555 int save_KeyTyped = KeyTyped; | |
1556 KeyTyped = FALSE; | |
1553 | 1557 |
1554 // Check if this script was sourced before to find its SID. | 1558 // Check if this script was sourced before to find its SID. |
1555 // Always use a new sequence number. | 1559 // Always use a new sequence number. |
1556 current_sctx.sc_seq = ++last_current_SID_seq; | 1560 current_sctx.sc_seq = ++last_current_SID_seq; |
1557 if (sid > 0) | 1561 if (sid > 0) |
1763 if (do_profiling == PROF_YES) | 1767 if (do_profiling == PROF_YES) |
1764 prof_child_exit(&wait_start); // leaving a child now | 1768 prof_child_exit(&wait_start); // leaving a child now |
1765 # endif | 1769 # endif |
1766 #endif | 1770 #endif |
1767 current_sctx = save_current_sctx; | 1771 current_sctx = save_current_sctx; |
1772 KeyTyped = save_KeyTyped; | |
1768 | 1773 |
1769 if (cookie.fp != NULL) | 1774 if (cookie.fp != NULL) |
1770 fclose(cookie.fp); | 1775 fclose(cookie.fp); |
1771 if (cookie.source_from_buf) | 1776 if (cookie.source_from_buf) |
1772 ga_clear_strings(&cookie.buflines); | 1777 ga_clear_strings(&cookie.buflines); |