Mercurial > vim
changeset 29475:fab3a46d0af7 v9.0.0079
patch 9.0.0079: error in autoload script not reported for 'foldexpr'
Commit: https://github.com/vim/vim/commit/6809ff978a5c5b798952db9fa663df9e1776f3ff
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jul 26 15:10:56 2022 +0100
patch 9.0.0079: error in autoload script not reported for 'foldexpr'
Problem: Error in autoload script not reported for 'foldexpr'.
Solution: Reset "emsg_off" when auto-loading a script. (closes https://github.com/vim/vim/issues/10685)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 26 Jul 2022 16:15:03 +0200 |
parents | 1101803eb1fa |
children | 2586309508be |
files | src/testdir/test_vim9_script.vim src/version.c src/vim9compile.c |
diffstat | 3 files changed, 35 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -3440,6 +3440,30 @@ def Test_error_in_autoload_script() delete(dir, 'rf') enddef +def Test_error_in_autoload_script_foldexpr() + var save_rtp = &rtp + mkdir('Xvim/autoload', 'p') + &runtimepath = 'Xvim' + + var lines =<< trim END + vim9script + eval [][0] + echomsg 'no error' + END + lines->writefile('Xvim/autoload/script.vim') + + lines =<< trim END + vim9script + import autoload 'script.vim' + &foldmethod = 'expr' + &foldexpr = 'script.Func()' + redraw + END + v9.CheckScriptFailure(lines, 'E684: List index out of range: 0') + + delete('Xvim', 'rf') +enddef + def Test_invalid_sid() assert_fails('func <SNR>1234_func', 'E123:')
--- a/src/version.c +++ b/src/version.c @@ -736,6 +736,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 79, +/**/ 78, /**/ 77,
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -610,12 +610,20 @@ find_imported(char_u *name, size_t len, ret = find_imported_in_script(name, len, current_sctx.sc_sid); if (ret != NULL && load && (ret->imp_flags & IMP_FLAGS_AUTOLOAD)) { - scid_T dummy; + scid_T dummy; + int save_emsg_off = emsg_off; + + // "emsg_off" will be set when evaluating an expression silently, but + // we do want to know about errors in a script. Also because it then + // aborts when an error is encountered. + emsg_off = FALSE; // script found before but not loaded yet ret->imp_flags &= ~IMP_FLAGS_AUTOLOAD; (void)do_source(SCRIPT_ITEM(ret->imp_sid)->sn_name, FALSE, DOSO_NONE, &dummy); + + emsg_off = save_emsg_off; } return ret; }