summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-08-31 21:17:39 +0200
committerBram Moolenaar <Bram@vim.org>2019-08-31 21:17:39 +0200
commitf9f24ce7a0e5988fedf2e2ff751818f9b07510a6 (patch)
treeaf3ede78a2dedfa82536fb134d22dbe6c9a5033c /src
parent5d69fdb7c4b91faf2d92b8d449cc9460f3035fb3 (diff)
patch 8.1.1953: more functions can be used as a methodv8.1.1953
Problem: More functions can be used as a method. Solution: Allow more functions to be used as a method.
Diffstat (limited to 'src')
-rw-r--r--src/evalfunc.c36
-rw-r--r--src/testdir/test_blob.vim2
-rw-r--r--src/testdir/test_breakindent.vim4
-rw-r--r--src/testdir/test_delete.vim2
-rw-r--r--src/testdir/test_functions.vim25
-rw-r--r--src/testdir/test_getcwd.vim2
-rw-r--r--src/testdir/test_history.vim8
-rw-r--r--src/testdir/test_listdict.vim2
-rw-r--r--src/testdir/test_syn_attr.vim4
-rw-r--r--src/testdir/test_termcodes.vim2
-rw-r--r--src/testdir/test_true_false.vim2
-rw-r--r--src/version.c2
12 files changed, 56 insertions, 35 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 4561f08a34..dda98748a2 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -595,33 +595,33 @@ static funcentry_T global_functions[] =
{"globpath", 2, 5, FEARG_2, f_globpath},
{"has", 1, 1, 0, f_has},
{"has_key", 2, 2, FEARG_1, f_has_key},
- {"haslocaldir", 0, 2, 0, f_haslocaldir},
- {"hasmapto", 1, 3, 0, f_hasmapto},
- {"highlightID", 1, 1, 0, f_hlID}, // obsolete
- {"highlight_exists",1, 1, 0, f_hlexists}, // obsolete
- {"histadd", 2, 2, 0, f_histadd},
- {"histdel", 1, 2, 0, f_histdel},
- {"histget", 1, 2, 0, f_histget},
- {"histnr", 1, 1, 0, f_histnr},
- {"hlID", 1, 1, 0, f_hlID},
- {"hlexists", 1, 1, 0, f_hlexists},
+ {"haslocaldir", 0, 2, FEARG_1, f_haslocaldir},
+ {"hasmapto", 1, 3, FEARG_1, f_hasmapto},
+ {"highlightID", 1, 1, FEARG_1, f_hlID}, // obsolete
+ {"highlight_exists",1, 1, FEARG_1, f_hlexists}, // obsolete
+ {"histadd", 2, 2, FEARG_2, f_histadd},
+ {"histdel", 1, 2, FEARG_1, f_histdel},
+ {"histget", 1, 2, FEARG_1, f_histget},
+ {"histnr", 1, 1, FEARG_1, f_histnr},
+ {"hlID", 1, 1, FEARG_1, f_hlID},
+ {"hlexists", 1, 1, FEARG_1, f_hlexists},
{"hostname", 0, 0, 0, f_hostname},
- {"iconv", 3, 3, 0, f_iconv},
- {"indent", 1, 1, 0, f_indent},
+ {"iconv", 3, 3, FEARG_1, f_iconv},
+ {"indent", 1, 1, FEARG_1, f_indent},
{"index", 2, 4, FEARG_1, f_index},
- {"input", 1, 3, 0, f_input},
- {"inputdialog", 1, 3, 0, f_inputdialog},
- {"inputlist", 1, 1, 0, f_inputlist},
+ {"input", 1, 3, FEARG_1, f_input},
+ {"inputdialog", 1, 3, FEARG_1, f_inputdialog},
+ {"inputlist", 1, 1, FEARG_1, f_inputlist},
{"inputrestore", 0, 0, 0, f_inputrestore},
{"inputsave", 0, 0, 0, f_inputsave},
- {"inputsecret", 1, 2, 0, f_inputsecret},
+ {"inputsecret", 1, 2, FEARG_1, f_inputsecret},
{"insert", 2, 3, FEARG_1, f_insert},
{"invert", 1, 1, FEARG_1, f_invert},
- {"isdirectory", 1, 1, 0, f_isdirectory},
+ {"isdirectory", 1, 1, FEARG_1, f_isdirectory},
#if defined(FEAT_FLOAT) && defined(HAVE_MATH_H)
{"isinf", 1, 1, FEARG_1, f_isinf},
#endif
- {"islocked", 1, 1, 0, f_islocked},
+ {"islocked", 1, 1, FEARG_1, f_islocked},
#if defined(FEAT_FLOAT) && defined(HAVE_MATH_H)
{"isnan", 1, 1, FEARG_1, f_isnan},
#endif
diff --git a/src/testdir/test_blob.vim b/src/testdir/test_blob.vim
index 273465d531..a4e9bea304 100644
--- a/src/testdir/test_blob.vim
+++ b/src/testdir/test_blob.vim
@@ -278,7 +278,7 @@ func Test_blob_index()
call assert_equal(2, index(0zDEADBEEF, 0xBE))
call assert_equal(-1, index(0zDEADBEEF, 0))
call assert_equal(2, index(0z11111111, 0x11, 2))
- call assert_equal(3, index(0z11110111, 0x11, 2))
+ call assert_equal(3, 0z11110111->index(0x11, 2))
call assert_equal(2, index(0z11111111, 0x11, -2))
call assert_equal(3, index(0z11110111, 0x11, -2))
diff --git a/src/testdir/test_breakindent.vim b/src/testdir/test_breakindent.vim
index 5b8971e7ec..65e258af54 100644
--- a/src/testdir/test_breakindent.vim
+++ b/src/testdir/test_breakindent.vim
@@ -411,7 +411,7 @@ func Test_breakindent11()
" test strdisplaywidth()
call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4')
let text = getline(2)
- let width = strlen(text[1:])+indent(2)+strlen(&sbr)*3 " text wraps 3 times
+ let width = strlen(text[1:]) + indent(2) + strlen(&sbr) * 3 " text wraps 3 times
call assert_equal(width, strdisplaywidth(text))
call s:close_windows('set sbr=')
endfunc
@@ -423,7 +423,7 @@ func Test_breakindent11_vartabs()
" test strdisplaywidth()
call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4 vts=4')
let text = getline(2)
- let width = strlen(text[1:])+indent(2)+strlen(&sbr)*3 " text wraps 3 times
+ let width = strlen(text[1:]) + 2->indent() + strlen(&sbr) * 3 " text wraps 3 times
call assert_equal(width, strdisplaywidth(text))
call s:close_windows('set sbr= vts&')
endfunc
diff --git a/src/testdir/test_delete.vim b/src/testdir/test_delete.vim
index b3e153e5b7..0ab516489a 100644
--- a/src/testdir/test_delete.vim
+++ b/src/testdir/test_delete.vim
@@ -32,7 +32,7 @@ func Test_recursive_delete()
call assert_equal(['a', 'b'], readfile('Xdir1/Xfile'))
call assert_true(isdirectory('Xdir1/subdir'))
call assert_equal(['a', 'b'], readfile('Xdir1/subdir/Xfile'))
- call assert_true(isdirectory('Xdir1/empty'))
+ call assert_true('Xdir1/empty'->isdirectory())
call assert_equal(0, delete('Xdir1', 'rf'))
call assert_false(isdirectory('Xdir1'))
call assert_equal(-1, delete('Xdir1', 'd'))
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index 1352eaa5df..2ffdc24fb7 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -1069,7 +1069,7 @@ endfunc
func Test_hlexists()
call assert_equal(0, hlexists('does_not_exist'))
- call assert_equal(0, hlexists('Number'))
+ call assert_equal(0, 'Number'->hlexists())
call assert_equal(0, highlight_exists('does_not_exist'))
call assert_equal(0, highlight_exists('Number'))
syntax on
@@ -1102,7 +1102,7 @@ endfunc
func Test_inputlist()
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>1\<cr>", 'tx')
call assert_equal(1, c)
- call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>2\<cr>", 'tx')
+ call feedkeys(":let c = ['Select color:', '1. red', '2. green', '3. blue']->inputlist()\<cr>2\<cr>", 'tx')
call assert_equal(2, c)
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>3\<cr>", 'tx')
call assert_equal(3, c)
@@ -1279,7 +1279,7 @@ func Test_reg_executing_and_recording()
let g:regs = []
func TestFunc() abort
let g:regs += [reg_executing()]
- let g:typed = input('?')
+ let g:typed = '?'->input()
let g:regs += [reg_executing()]
endfunc
call feedkeys("@qy\<CR>", 'xt')
@@ -1295,6 +1295,25 @@ func Test_reg_executing_and_recording()
unlet s:reg_stat
endfunc
+func Test_inputsecret()
+ map W :call TestFunc()<CR>
+ let @q = "W"
+ let g:typed1 = ''
+ let g:typed2 = ''
+ let g:regs = []
+ func TestFunc() abort
+ let g:typed1 = '?'->inputsecret()
+ let g:typed2 = inputsecret('password: ')
+ endfunc
+ call feedkeys("@qsomething\<CR>else\<CR>", 'xt')
+ call assert_equal("something", g:typed1)
+ call assert_equal("else", g:typed2)
+ delfunc TestFunc
+ unmap W
+ unlet g:typed1
+ unlet g:typed2
+endfunc
+
func Test_libcall_libcallnr()
if !has('libcall')
return
diff --git a/src/testdir/test_getcwd.vim b/src/testdir/test_getcwd.vim
index 50c940febe..e732546611 100644
--- a/src/testdir/test_getcwd.vim
+++ b/src/testdir/test_getcwd.vim
@@ -17,7 +17,7 @@ func GetCwdInfo(win, tab)
let lflag = haslocaldir(a:win)
else
let dirname = fnamemodify(getcwd(a:win, a:tab), mod)
- let lflag = haslocaldir(a:win, a:tab)
+ let lflag = a:win->haslocaldir(a:tab)
endif
return bufname . ' ' . dirname . ' ' . lflag
endfunc
diff --git a/src/testdir/test_history.vim b/src/testdir/test_history.vim
index 215fc0a55a..2d53474bb3 100644
--- a/src/testdir/test_history.vim
+++ b/src/testdir/test_history.vim
@@ -12,7 +12,7 @@ function History_Tests(hist)
call assert_equal(-1, histnr(a:hist))
call assert_equal('', histget(a:hist))
- call assert_true(histadd(a:hist, 'ls'))
+ call assert_true('ls'->histadd(a:hist))
call assert_true(histadd(a:hist, 'buffers'))
call assert_equal('buffers', histget(a:hist))
call assert_equal('ls', histget(a:hist, -2))
@@ -21,14 +21,14 @@ function History_Tests(hist)
call assert_equal('', histget(a:hist, -5))
call assert_equal(2, histnr(a:hist))
call assert_true(histdel(a:hist, 2))
- call assert_false(histdel(a:hist, 7))
+ call assert_false(a:hist->histdel(7))
call assert_equal(1, histnr(a:hist))
call assert_equal('ls', histget(a:hist, -1))
call assert_true(histadd(a:hist, 'buffers'))
call assert_true(histadd(a:hist, 'ls'))
- call assert_equal('ls', histget(a:hist, -1))
- call assert_equal(4, histnr(a:hist))
+ call assert_equal('ls', a:hist->histget(-1))
+ call assert_equal(4, a:hist->histnr())
let a=execute('history ' . a:hist)
call assert_match("^\n # \\S* history\n 3 buffers\n> 4 ls$", a)
diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim
index 961f27469b..557687b822 100644
--- a/src/testdir/test_listdict.vim
+++ b/src/testdir/test_listdict.vim
@@ -565,7 +565,7 @@ func Test_lockvar_script_autoload()
set rtp+=./sautest
lockvar g:footest#x
unlockvar g:footest#x
- call assert_equal(-1, islocked('g:footest#x'))
+ call assert_equal(-1, 'g:footest#x'->islocked())
call assert_equal(0, exists('g:footest#x'))
call assert_equal(1, g:footest#x)
let &rtp = old_rtp
diff --git a/src/testdir/test_syn_attr.vim b/src/testdir/test_syn_attr.vim
index 27f9fc0dde..cc2067818c 100644
--- a/src/testdir/test_syn_attr.vim
+++ b/src/testdir/test_syn_attr.vim
@@ -3,7 +3,7 @@
func Test_missing_attr()
hi Mine term=bold cterm=italic
call assert_equal('Mine', synIDattr(hlID("Mine"), "name"))
- call assert_equal('', synIDattr(hlID("Mine"), "bg", 'term'))
+ call assert_equal('', synIDattr("Mine"->hlID(), "bg", 'term'))
call assert_equal('1', synIDattr(hlID("Mine"), "bold", 'term'))
call assert_equal('1', synIDattr(hlID("Mine"), "italic", 'cterm'))
hi Mine term=reverse cterm=inverse
@@ -12,7 +12,7 @@ func Test_missing_attr()
hi Mine term=underline cterm=standout gui=undercurl
call assert_equal('1', synIDattr(hlID("Mine"), "underline", 'term'))
call assert_equal('1', synIDattr(hlID("Mine"), "standout", 'cterm'))
- call assert_equal('1', synIDattr(hlID("Mine"), "undercurl", 'gui'))
+ call assert_equal('1', synIDattr("Mine"->hlID(), "undercurl", 'gui'))
hi Mine term=NONE cterm=NONE gui=NONE
call assert_equal('', synIDattr(hlID("Mine"), "bold", 'term'))
call assert_equal('', synIDattr(hlID("Mine"), "italic", 'cterm'))
diff --git a/src/testdir/test_termcodes.vim b/src/testdir/test_termcodes.vim
index 75eaa7b8d7..7b71d60ae9 100644
--- a/src/testdir/test_termcodes.vim
+++ b/src/testdir/test_termcodes.vim
@@ -33,7 +33,7 @@ func TerminalEscapeCode(code, row, col, m)
" need to use byte encoding here.
let str = list2str([a:code + 0x20, a:col + 0x20, a:row + 0x20])
if has('iconv')
- let bytes = iconv(str, 'utf-8', 'latin1')
+ let bytes = str->iconv('utf-8', 'latin1')
else
" Hopefully the numbers are not too big.
let bytes = str
diff --git a/src/testdir/test_true_false.vim b/src/testdir/test_true_false.vim
index a23f2cc4b1..346b43243b 100644
--- a/src/testdir/test_true_false.vim
+++ b/src/testdir/test_true_false.vim
@@ -100,7 +100,7 @@ func Test_true_false_arg()
call Try_arg_true_false('maparg("asdf", "i", %v%)', "", "asdff")
call Try_arg_true_false('FilterMapArg(maparg("asdf", "i", 1, %v%))', "asdff", {'rhs': 'asdff'})
- call Try_arg_true_false('hasmapto("asdf", "i", %v%)', 0, 1)
+ call Try_arg_true_false('"asdf"->hasmapto("i", %v%)', 0, 1)
new colored
call setline(1, '<here>')
diff --git a/src/version.c b/src/version.c
index 067e176d81..aec889d56a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1953,
+/**/
1952,
/**/
1951,