vim-patch:9.0.1431: getscriptinfo() loops even when specific SID is given

Problem:    getscriptinfo() loops even when specific SID is given.
Solution:   Only loop when needed.  Give a clearer error message.
            (closes vim/vim#12207)

2d68b722e3
This commit is contained in:
zeertzjq
2023-04-15 20:47:04 +08:00
parent e9b4f51051
commit c5ec823a14
2 changed files with 27 additions and 11 deletions

View File

@@ -93,6 +93,16 @@ func Test_getscriptinfo()
call assert_fails("echo getscriptinfo('foobar')", 'E1206:')
call assert_fails("echo getscriptinfo({'sid': []})", 'E745:')
call assert_fails("echo getscriptinfo({'sid': {}})", 'E728:')
call assert_fails("echo getscriptinfo({'sid': 0})", 'E475:')
call assert_fails("echo getscriptinfo({'sid': -1})", 'E475:')
call assert_fails("echo getscriptinfo({'sid': -999})", 'E475:')
echo getscriptinfo({'sid': '1'})
" call assert_fails("vim9cmd echo getscriptinfo({'sid': '1'})", 'E1030:')
let max_sid = max(map(getscriptinfo(), { k, v -> v.sid }))
call assert_equal([], getscriptinfo({'sid': max_sid + 1}))
call delete('X22script91')
endfunc