Mercurial > vim
comparison src/testdir/test_fold.vim @ 26743:c2c40cefc17b v8.2.3900
patch 8.2.3900: it is not easy to use a script-local function for an option
Commit: https://github.com/vim/vim/commit/8bb65f230d3025037f34021a72616038da0601ee
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sun Dec 26 10:51:39 2021 +0000
patch 8.2.3900: it is not easy to use a script-local function for an option
Problem: It is not easy to use a script-local function for an option.
Solution: recognize s: and <SID> at the start of the expression. (Yegappan
Lakshmanan, closes #9401)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 26 Dec 2021 12:00:04 +0100 |
parents | eab30779c97c |
children | 31c23760d590 |
comparison
equal
deleted
inserted
replaced
26742:00732e690ee8 | 26743:c2c40cefc17b |
---|---|
1380 call assert_beeps('normal ]z') | 1380 call assert_beeps('normal ]z') |
1381 call assert_equal(4, line('.')) | 1381 call assert_equal(4, line('.')) |
1382 bw! | 1382 bw! |
1383 endfunc | 1383 endfunc |
1384 | 1384 |
1385 " Test for using a script-local function for 'foldexpr' | |
1386 func Test_foldexpr_scriptlocal_func() | |
1387 func! s:FoldFunc() | |
1388 let g:FoldLnum = v:lnum | |
1389 endfunc | |
1390 new | only | |
1391 call setline(1, 'abc') | |
1392 let g:FoldLnum = 0 | |
1393 set foldmethod=expr foldexpr=s:FoldFunc() | |
1394 redraw! | |
1395 call assert_equal(expand('<SID>') .. 'FoldFunc()', &foldexpr) | |
1396 call assert_equal(1, g:FoldLnum) | |
1397 set foldmethod& foldexpr= | |
1398 bw! | |
1399 new | only | |
1400 call setline(1, 'abc') | |
1401 let g:FoldLnum = 0 | |
1402 set foldmethod=expr foldexpr=<SID>FoldFunc() | |
1403 redraw! | |
1404 call assert_equal(expand('<SID>') .. 'FoldFunc()', &foldexpr) | |
1405 call assert_equal(1, g:FoldLnum) | |
1406 set foldmethod& foldexpr= | |
1407 delfunc s:FoldFunc | |
1408 bw! | |
1409 endfunc | |
1410 | |
1385 " vim: shiftwidth=2 sts=2 expandtab | 1411 " vim: shiftwidth=2 sts=2 expandtab |