diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-09-06 21:34:30 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-09-06 21:34:30 +0200 |
commit | 196b4664432f932625cfb6371dc42c24efe6c203 (patch) | |
tree | 95294d46aa15e3fccbee2422f352b46958d9f593 /src | |
parent | 16b58ae9f36e9675c34d942f5d5f8c8a7914dbc4 (diff) | |
download | vim-git-196b4664432f932625cfb6371dc42c24efe6c203.tar.gz |
patch 8.1.1993: more functions can be used as methodsv8.1.1993
Problem: More functions can be used as methods.
Solution: Make various functions usable as a method.
Diffstat (limited to 'src')
-rw-r--r-- | src/evalfunc.c | 30 | ||||
-rw-r--r-- | src/testdir/test_bufline.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_charsearch.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_clientserver.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_cmdline.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_cursor_func.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_diffmode.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_environ.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_functions.vim | 4 | ||||
-rw-r--r-- | src/testdir/test_matchadd_conceal_utf8.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_popupwin.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_search.vim | 37 | ||||
-rw-r--r-- | src/testdir/test_searchpos.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_utf8.vim | 2 | ||||
-rw-r--r-- | src/version.c | 2 |
15 files changed, 66 insertions, 29 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index c790913b3..f302df773 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -700,27 +700,27 @@ static funcentry_T global_functions[] = #ifdef FEAT_RUBY {"rubyeval", 1, 1, FEARG_1, f_rubyeval}, #endif - {"screenattr", 2, 2, 0, f_screenattr}, - {"screenchar", 2, 2, 0, f_screenchar}, - {"screenchars", 2, 2, 0, f_screenchars}, + {"screenattr", 2, 2, FEARG_1, f_screenattr}, + {"screenchar", 2, 2, FEARG_1, f_screenchar}, + {"screenchars", 2, 2, FEARG_1, f_screenchars}, {"screencol", 0, 0, 0, f_screencol}, - {"screenpos", 3, 3, 0, f_screenpos}, + {"screenpos", 3, 3, FEARG_1, f_screenpos}, {"screenrow", 0, 0, 0, f_screenrow}, - {"screenstring", 2, 2, 0, f_screenstring}, - {"search", 1, 4, 0, f_search}, - {"searchdecl", 1, 3, 0, f_searchdecl}, + {"screenstring", 2, 2, FEARG_1, f_screenstring}, + {"search", 1, 4, FEARG_1, f_search}, + {"searchdecl", 1, 3, FEARG_1, f_searchdecl}, {"searchpair", 3, 7, 0, f_searchpair}, {"searchpairpos", 3, 7, 0, f_searchpairpos}, - {"searchpos", 1, 4, 0, f_searchpos}, - {"server2client", 2, 2, 0, f_server2client}, + {"searchpos", 1, 4, FEARG_1, f_searchpos}, + {"server2client", 2, 2, FEARG_1, f_server2client}, {"serverlist", 0, 0, 0, f_serverlist}, - {"setbufline", 3, 3, 0, f_setbufline}, - {"setbufvar", 3, 3, 0, f_setbufvar}, - {"setcharsearch", 1, 1, 0, f_setcharsearch}, - {"setcmdpos", 1, 1, 0, f_setcmdpos}, - {"setenv", 2, 2, 0, f_setenv}, + {"setbufline", 3, 3, FEARG_3, f_setbufline}, + {"setbufvar", 3, 3, FEARG_3, f_setbufvar}, + {"setcharsearch", 1, 1, FEARG_1, f_setcharsearch}, + {"setcmdpos", 1, 1, FEARG_1, f_setcmdpos}, + {"setenv", 2, 2, FEARG_2, f_setenv}, {"setfperm", 2, 2, FEARG_1, f_setfperm}, - {"setline", 2, 2, 0, f_setline}, + {"setline", 2, 2, FEARG_2, f_setline}, {"setloclist", 2, 4, 0, f_setloclist}, {"setmatches", 1, 2, 0, f_setmatches}, {"setpos", 2, 2, 0, f_setpos}, diff --git a/src/testdir/test_bufline.vim b/src/testdir/test_bufline.vim index 50f7275df..3c3c89c61 100644 --- a/src/testdir/test_bufline.vim +++ b/src/testdir/test_bufline.vim @@ -20,7 +20,7 @@ func Test_setbufline_getbufline() let b = bufnr('%') wincmd w call assert_equal(1, setbufline(b, 5, ['x'])) - call assert_equal(1, setbufline(bufnr('$') + 1, 1, ['x'])) + call assert_equal(1, ['x']->setbufline(bufnr('$') + 1, 1)) call assert_equal(0, setbufline(b, 4, ['d', 'e'])) call assert_equal(['c'], b->getbufline(3)) call assert_equal(['d'], getbufline(b, 4)) diff --git a/src/testdir/test_charsearch.vim b/src/testdir/test_charsearch.vim index 17a49e02b..6f09e85a4 100644 --- a/src/testdir/test_charsearch.vim +++ b/src/testdir/test_charsearch.vim @@ -20,7 +20,7 @@ func Test_charsearch() " check that setcharsearch() changes the settings. 3 normal! ylfep - call setcharsearch({'char': 'k'}) + eval {'char': 'k'}->setcharsearch() normal! ;p call setcharsearch({'forward': 0}) normal! $;p diff --git a/src/testdir/test_clientserver.vim b/src/testdir/test_clientserver.vim index 2e4a66ef8..f358117a8 100644 --- a/src/testdir/test_clientserver.vim +++ b/src/testdir/test_clientserver.vim @@ -73,7 +73,7 @@ func Test_client_server() call remote_send(name, ":call server2client(expand('<client>'), 'got it')\<CR>", 'g:myserverid') call assert_equal('got it', g:myserverid->remote_read(2)) - call remote_send(name, ":call server2client(expand('<client>'), 'another')\<CR>", 'g:myserverid') + call remote_send(name, ":eval expand('<client>')->server2client('another')\<CR>", 'g:myserverid') let peek_result = 'nothing' let r = g:myserverid->remote_peek('peek_result') " unpredictable whether the result is already available. diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim index 6ed7848a2..26a50e010 100644 --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -672,7 +672,7 @@ func Test_setcmdpos() call assert_equal('"12ab', @:) " setcmdpos() returns 1 when not editing the command line. - call assert_equal(1, setcmdpos(3)) + call assert_equal(1, 3->setcmdpos()) endfunc func Test_cmdline_overstrike() diff --git a/src/testdir/test_cursor_func.vim b/src/testdir/test_cursor_func.vim index fbe7be7b7..4fc28c9cf 100644 --- a/src/testdir/test_cursor_func.vim +++ b/src/testdir/test_cursor_func.vim @@ -87,7 +87,7 @@ func Test_screenpos() call assert_equal({'row': winrow, \ 'col': wincol + 13, \ 'curscol': wincol + 13, - \ 'endcol': wincol + 13}, screenpos(winid, 1, 7)) + \ 'endcol': wincol + 13}, winid->screenpos(1, 7)) call assert_equal({'row': winrow + 2, \ 'col': wincol + 1, \ 'curscol': wincol + 1, diff --git a/src/testdir/test_diffmode.vim b/src/testdir/test_diffmode.vim index bbdbfb8c0..8280a2cb7 100644 --- a/src/testdir/test_diffmode.vim +++ b/src/testdir/test_diffmode.vim @@ -330,7 +330,7 @@ func Test_diffoff() call setline(1, ['One', '', 'Two', 'Three']) diffthis redraw - call assert_notequal(normattr, screenattr(1, 1)) + call assert_notequal(normattr, 1->screenattr(1)) diffoff! redraw call assert_equal(normattr, screenattr(1, 1)) diff --git a/src/testdir/test_environ.vim b/src/testdir/test_environ.vim index ba61b17d5..b52d1020b 100644 --- a/src/testdir/test_environ.vim +++ b/src/testdir/test_environ.vim @@ -18,7 +18,7 @@ endfunc func Test_setenv() unlet! $TESTENV - call setenv('TEST ENV', 'foo') + eval 'foo'->setenv('TEST ENV') call assert_equal('foo', getenv('TEST ENV')) call setenv('TEST ENV', v:null) call assert_equal(v:null, getenv('TEST ENV')) diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index dfd6a933b..1d8d74ddb 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -1137,7 +1137,7 @@ func Test_setbufvar_options() wincmd h let wh = winheight('.') let dummy_buf = bufnr('dummy_buf2', v:true) - call setbufvar(dummy_buf, '&buftype', 'nofile') + eval 'nofile'->setbufvar(dummy_buf, '&buftype') execute 'belowright vertical split #' . dummy_buf call assert_equal(wh, winheight('.')) @@ -1413,7 +1413,7 @@ func Test_func_range_with_edit() " is invalid in that buffer. call writefile(['just one line'], 'Xfuncrange2') new - call setline(1, 10->range()) + eval 10->range()->setline(1) write Xfuncrange1 call assert_fails('5,8call EditAnotherFile()', 'E16:') diff --git a/src/testdir/test_matchadd_conceal_utf8.vim b/src/testdir/test_matchadd_conceal_utf8.vim index 98ed2cbe6..2cdb06218 100644 --- a/src/testdir/test_matchadd_conceal_utf8.vim +++ b/src/testdir/test_matchadd_conceal_utf8.vim @@ -10,7 +10,7 @@ endif func s:screenline(lnum) abort let line = [] for c in range(1, winwidth(0)) - call add(line, nr2char(screenchar(a:lnum, c))) + call add(line, nr2char(a:lnum->screenchar(c))) endfor return s:trim(join(line, '')) endfunc diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim index 03cada32a..e6b4137cd 100644 --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -833,7 +833,7 @@ func Test_popup_time() sleep 700m redraw - let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '') + let line = join(map(range(1, 5), '1->screenstring(v:val)'), '') call assert_equal('hello', line) call popup_create('on the command line', #{ diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim index dbe4c2a4d..190755a2d 100644 --- a/src/testdir/test_search.vim +++ b/src/testdir/test_search.vim @@ -1280,7 +1280,7 @@ func Test_search_match_at_curpos() normal gg - call search('foobar', 'c') + eval 'foobar'->search('c') call assert_equal([1, 1], [line('.'), col('.')]) normal j @@ -1318,3 +1318,38 @@ func Test_search_display_pattern() set norl endif endfunc + +func Test_searchdecl() + let lines =<< trim END + int global; + + func() + { + int global; + if (cond) { + int local; + } + int local; + // comment + } + END + new + call setline(1, lines) + 10 + call assert_equal(0, searchdecl('local', 0, 0)) + call assert_equal(7, getcurpos()[1]) + + 10 + call assert_equal(0, 'local'->searchdecl(0, 1)) + call assert_equal(9, getcurpos()[1]) + + 10 + call assert_equal(0, searchdecl('global')) + call assert_equal(5, getcurpos()[1]) + + 10 + call assert_equal(0, searchdecl('global', 1)) + call assert_equal(1, getcurpos()[1]) + + bwipe! +endfunc diff --git a/src/testdir/test_searchpos.vim b/src/testdir/test_searchpos.vim index 8dffddc09..5827cbc43 100644 --- a/src/testdir/test_searchpos.vim +++ b/src/testdir/test_searchpos.vim @@ -7,7 +7,7 @@ func Test_searchpos() call cursor(1, 1) call assert_equal([1, 1, 2], searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')) call cursor(1, 2) - call assert_equal([2, 1, 1], searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')) + call assert_equal([2, 1, 1], '\%(\([a-z]\)\|\_.\)\{-}xyz'->searchpos('pcW')) set cpo-=c call cursor(1, 2) call assert_equal([1, 2, 2], searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')) diff --git a/src/testdir/test_utf8.vim b/src/testdir/test_utf8.vim index 9470855af..fa0568e59 100644 --- a/src/testdir/test_utf8.vim +++ b/src/testdir/test_utf8.vim @@ -112,7 +112,7 @@ func Test_screenchar_utf8() call setline(1, ["ABC\u0308"]) redraw call assert_equal([0x0041], screenchars(1, 1)) - call assert_equal([0x0042], screenchars(1, 2)) + call assert_equal([0x0042], 1->screenchars(2)) call assert_equal([0x0043, 0x0308], screenchars(1, 3)) call assert_equal("A", screenstring(1, 1)) call assert_equal("B", screenstring(1, 2)) diff --git a/src/version.c b/src/version.c index a21104c59..05e882908 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1993, +/**/ 1992, /**/ 1991, |