mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
patch 8.2.0992: Vim9: crash when using :import in the Vim command
Problem: Vim9: crash when using :import in the Vim command. Solution: Give an error when using :import outside of a script. (closes #6271)
This commit is contained in:
@@ -107,16 +107,18 @@ func RunVimInTerminal(arguments, options)
|
||||
|
||||
call TermWait(buf)
|
||||
|
||||
" Wait for "All" or "Top" of the ruler to be shown in the last line or in
|
||||
" the status line of the last window. This can be quite slow (e.g. when
|
||||
" using valgrind).
|
||||
" If it fails then show the terminal contents for debugging.
|
||||
try
|
||||
call WaitFor({-> len(term_getline(buf, rows)) >= cols - 1 || len(term_getline(buf, rows - statusoff)) >= cols - 1})
|
||||
catch /timed out after/
|
||||
let lines = map(range(1, rows), {key, val -> term_getline(buf, val)})
|
||||
call assert_report('RunVimInTerminal() failed, screen contents: ' . join(lines, "<NL>"))
|
||||
endtry
|
||||
if get(a:options, 'wait_for_ruler', 1)
|
||||
" Wait for "All" or "Top" of the ruler to be shown in the last line or in
|
||||
" the status line of the last window. This can be quite slow (e.g. when
|
||||
" using valgrind).
|
||||
" If it fails then show the terminal contents for debugging.
|
||||
try
|
||||
call WaitFor({-> len(term_getline(buf, rows)) >= cols - 1 || len(term_getline(buf, rows - statusoff)) >= cols - 1})
|
||||
catch /timed out after/
|
||||
let lines = map(range(1, rows), {key, val -> term_getline(buf, val)})
|
||||
call assert_report('RunVimInTerminal() failed, screen contents: ' . join(lines, "<NL>"))
|
||||
endtry
|
||||
endif
|
||||
|
||||
" Starting a terminal to run Vim is always considered flaky.
|
||||
let g:test_is_flaky = 1
|
||||
|
@@ -1,6 +1,7 @@
|
||||
" Test various aspects of the Vim9 script language.
|
||||
|
||||
source check.vim
|
||||
source term_util.vim
|
||||
source view_util.vim
|
||||
source vim9.vim
|
||||
|
||||
@@ -777,6 +778,25 @@ def Test_vim9script_fails()
|
||||
assert_fails('export something', 'E1043')
|
||||
enddef
|
||||
|
||||
def Test_import_fails_without_script()
|
||||
CheckRunVimInTerminal
|
||||
|
||||
let export =<< trim END
|
||||
vim9script
|
||||
export def Foo(): number
|
||||
return 0
|
||||
enddef
|
||||
END
|
||||
writefile(export, 'Xexport.vim')
|
||||
|
||||
let buf = RunVimInTerminal('-c "import Foo from ''./Xexport.vim''"', #{
|
||||
rows: 6, wait_for_ruler: 0})
|
||||
WaitForAssert({-> assert_match('^E1094:', term_getline(buf, 5))})
|
||||
|
||||
delete('Xexport.vim')
|
||||
StopVimInTerminal(buf)
|
||||
enddef
|
||||
|
||||
def Test_vim9script_reload_import()
|
||||
let lines =<< trim END
|
||||
vim9script
|
||||
|
Reference in New Issue
Block a user