Mercurial > vim
comparison src/testdir/test_ins_complete.vim @ 26452:65b4109a4297 v8.2.3756
patch 8.2.3756: might crash when callback is not valid
Commit: https://github.com/vim/vim/commit/4dc24eb5adbcc76838fae1e900936dd230209d96
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Tue Dec 7 12:23:57 2021 +0000
patch 8.2.3756: might crash when callback is not valid
Problem: might crash when callback is not valid.
Solution: Check for valid callback. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/9293)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 07 Dec 2021 13:30:05 +0100 |
parents | 65ab0b035dd8 |
children | 7eaf61a67d18 |
comparison
equal
deleted
inserted
replaced
26451:27720705109b | 26452:65b4109a4297 |
---|---|
1072 new | only | 1072 new | only |
1073 let g:MycompleteFunc2_args = [] | 1073 let g:MycompleteFunc2_args = [] |
1074 call assert_fails('call feedkeys("A\<C-X>\<C-U>\<Esc>", "x")', 'E117:') | 1074 call assert_fails('call feedkeys("A\<C-X>\<C-U>\<Esc>", "x")', 'E117:') |
1075 call assert_equal([], g:MycompleteFunc2_args) | 1075 call assert_equal([], g:MycompleteFunc2_args) |
1076 | 1076 |
1077 " set 'completefunc' to a non-existing function | |
1078 set completefunc=MycompleteFunc2 | |
1079 call setline(1, 'five') | |
1080 call assert_fails("set completefunc=function('NonExistingFunc')", 'E700:') | |
1081 call assert_fails("let &completefunc = function('NonExistingFunc')", 'E700:') | |
1082 let g:MycompleteFunc2_args = [] | |
1083 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x') | |
1084 call assert_equal([[1, ''], [0, 'five']], g:MycompleteFunc2_args) | |
1085 | |
1077 " cleanup | 1086 " cleanup |
1078 delfunc MycompleteFunc1 | 1087 delfunc MycompleteFunc1 |
1079 delfunc MycompleteFunc2 | 1088 delfunc MycompleteFunc2 |
1080 delfunc MycompleteFunc3 | 1089 delfunc MycompleteFunc3 |
1081 set completefunc& | 1090 set completefunc& |
1283 new | only | 1292 new | only |
1284 let g:MyomniFunc2_args = [] | 1293 let g:MyomniFunc2_args = [] |
1285 call assert_fails('call feedkeys("A\<C-X>\<C-O>\<Esc>", "x")', 'E117:') | 1294 call assert_fails('call feedkeys("A\<C-X>\<C-O>\<Esc>", "x")', 'E117:') |
1286 call assert_equal([], g:MyomniFunc2_args) | 1295 call assert_equal([], g:MyomniFunc2_args) |
1287 | 1296 |
1297 " set 'omnifunc' to a non-existing function | |
1298 set omnifunc=MyomniFunc2 | |
1299 call setline(1, 'nine') | |
1300 call assert_fails("set omnifunc=function('NonExistingFunc')", 'E700:') | |
1301 call assert_fails("let &omnifunc = function('NonExistingFunc')", 'E700:') | |
1302 let g:MyomniFunc2_args = [] | |
1303 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x') | |
1304 call assert_equal([[1, ''], [0, 'nine']], g:MyomniFunc2_args) | |
1305 | |
1288 " cleanup | 1306 " cleanup |
1289 delfunc MyomniFunc1 | 1307 delfunc MyomniFunc1 |
1290 delfunc MyomniFunc2 | 1308 delfunc MyomniFunc2 |
1291 delfunc MyomniFunc3 | 1309 delfunc MyomniFunc3 |
1292 set omnifunc& | 1310 set omnifunc& |
1520 call setline(1, 'sun') | 1538 call setline(1, 'sun') |
1521 let g:MytsrFunc4_args = [] | 1539 let g:MytsrFunc4_args = [] |
1522 call feedkeys("A\<C-X>\<C-T>\<Esc>", "x") | 1540 call feedkeys("A\<C-X>\<C-T>\<Esc>", "x") |
1523 call assert_equal('sunday', getline(1)) | 1541 call assert_equal('sunday', getline(1)) |
1524 call assert_equal([[1, ''], [0, 'sun']], g:MytsrFunc4_args) | 1542 call assert_equal([[1, ''], [0, 'sun']], g:MytsrFunc4_args) |
1543 %bw! | |
1544 | |
1545 " set 'thesaurusfunc' to a non-existing function | |
1546 set thesaurusfunc=MytsrFunc2 | |
1547 call setline(1, 'ten') | |
1548 call assert_fails("set thesaurusfunc=function('NonExistingFunc')", 'E700:') | |
1549 call assert_fails("let &thesaurusfunc = function('NonExistingFunc')", 'E700:') | |
1550 let g:MytsrFunc2_args = [] | |
1551 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x') | |
1552 call assert_equal([[1, ''], [0, 'ten']], g:MytsrFunc2_args) | |
1525 | 1553 |
1526 " cleanup | 1554 " cleanup |
1527 set thesaurusfunc& | 1555 set thesaurusfunc& |
1528 delfunc MytsrFunc1 | 1556 delfunc MytsrFunc1 |
1529 delfunc MytsrFunc2 | 1557 delfunc MytsrFunc2 |