forked from aniani/vim
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)
This commit is contained in:
@@ -1334,10 +1334,10 @@ errret:
|
|||||||
* When "ret_sid" is not NULL and we loaded the script before, don't load it
|
* When "ret_sid" is not NULL and we loaded the script before, don't load it
|
||||||
* again.
|
* again.
|
||||||
*
|
*
|
||||||
* The 'eap' argument is used when sourcing lines from a buffer instead of a
|
* The "eap" argument is used when sourcing lines from a buffer instead of a
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
* If 'clearvars' is TRUE, then for scripts which are loaded more than
|
* If "clearvars" is TRUE, then for scripts which are loaded more than
|
||||||
* once, clear all the functions and variables previously defined in that
|
* once, clear all the functions and variables previously defined in that
|
||||||
* script.
|
* script.
|
||||||
*
|
*
|
||||||
@@ -1538,6 +1538,7 @@ do_source_ext(
|
|||||||
current_sctx.sc_version = SCRIPT_VERSION_VIM9;
|
current_sctx.sc_version = SCRIPT_VERSION_VIM9;
|
||||||
else
|
else
|
||||||
current_sctx.sc_version = 1; // default script version
|
current_sctx.sc_version = 1; // default script version
|
||||||
|
current_sctx.sc_lnum = 0;
|
||||||
|
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
# ifdef FEAT_PROFILE
|
# ifdef FEAT_PROFILE
|
||||||
@@ -1549,7 +1550,10 @@ do_source_ext(
|
|||||||
// Also starts profiling timer for nested script.
|
// Also starts profiling timer for nested script.
|
||||||
save_funccal(&funccalp_entry);
|
save_funccal(&funccalp_entry);
|
||||||
|
|
||||||
current_sctx.sc_lnum = 0;
|
// Reset "KeyTyped" to avoid some commands thinking they are invoked
|
||||||
|
// interactively. E.g. defining a function would output indent.
|
||||||
|
int save_KeyTyped = KeyTyped;
|
||||||
|
KeyTyped = FALSE;
|
||||||
|
|
||||||
// Check if this script was sourced before to find its SID.
|
// Check if this script was sourced before to find its SID.
|
||||||
// Always use a new sequence number.
|
// Always use a new sequence number.
|
||||||
@@ -1765,6 +1769,7 @@ almosttheend:
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
current_sctx = save_current_sctx;
|
current_sctx = save_current_sctx;
|
||||||
|
KeyTyped = save_KeyTyped;
|
||||||
|
|
||||||
if (cookie.fp != NULL)
|
if (cookie.fp != NULL)
|
||||||
fclose(cookie.fp);
|
fclose(cookie.fp);
|
||||||
|
6
src/testdir/dumps/Test_keytyped_in_nested_func.dump
Normal file
6
src/testdir/dumps/Test_keytyped_in_nested_func.dump
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
| +0&#ffffff0@74
|
||||||
|
|~+0#4040ff13&| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|:+0#0000000&|"> @72
|
@@ -4413,6 +4413,48 @@ def Test_invalid_redir()
|
|||||||
delfunc g:Ttwo
|
delfunc g:Ttwo
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
func Test_keytyped_in_nested_function()
|
||||||
|
CheckRunVimInTerminal
|
||||||
|
|
||||||
|
call Run_Test_keytyped_in_nested_function()
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
def Run_Test_keytyped_in_nested_function()
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
autocmd CmdlineEnter * sample#Init()
|
||||||
|
|
||||||
|
exe 'set rtp=' .. getcwd() .. '/Xrtpdir'
|
||||||
|
END
|
||||||
|
writefile(lines, 'Xkeytyped', 'D')
|
||||||
|
|
||||||
|
var dir = 'Xrtpdir/autoload'
|
||||||
|
mkdir(dir, 'pR')
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
export def Init(): void
|
||||||
|
cnoremap <expr>" <SID>Quote('"')
|
||||||
|
enddef
|
||||||
|
def Quote(str: string): string
|
||||||
|
def InPair(): number
|
||||||
|
return 0
|
||||||
|
enddef
|
||||||
|
return str
|
||||||
|
enddef
|
||||||
|
END
|
||||||
|
writefile(lines, dir .. '/sample.vim')
|
||||||
|
|
||||||
|
var buf = g:RunVimInTerminal('-S Xkeytyped', {rows: 6})
|
||||||
|
|
||||||
|
term_sendkeys(buf, ':"')
|
||||||
|
g:VerifyScreenDump(buf, 'Test_keytyped_in_nested_func', {})
|
||||||
|
|
||||||
|
# clean up
|
||||||
|
term_sendkeys(buf, "\<Esc>")
|
||||||
|
g:StopVimInTerminal(buf)
|
||||||
|
enddef
|
||||||
|
|
||||||
" The following messes up syntax highlight, keep near the end.
|
" The following messes up syntax highlight, keep near the end.
|
||||||
if has('python3')
|
if has('python3')
|
||||||
def Test_python3_command()
|
def Test_python3_command()
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1130,
|
||||||
/**/
|
/**/
|
||||||
1129,
|
1129,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -987,7 +987,14 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx, garray_T *lines_to_free)
|
|||||||
goto theend;
|
goto theend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure "KeyTyped" is not set, it may cause indent to be written.
|
||||||
|
int save_KeyTyped = KeyTyped;
|
||||||
|
KeyTyped = FALSE;
|
||||||
|
|
||||||
ufunc = define_function(eap, lambda_name, lines_to_free, FALSE);
|
ufunc = define_function(eap, lambda_name, lines_to_free, FALSE);
|
||||||
|
|
||||||
|
KeyTyped = save_KeyTyped;
|
||||||
|
|
||||||
if (ufunc == NULL)
|
if (ufunc == NULL)
|
||||||
{
|
{
|
||||||
r = eap->skip ? OK : FAIL;
|
r = eap->skip ? OK : FAIL;
|
||||||
|
Reference in New Issue
Block a user