Merge pull request #17272 from zeertzjq/vim-8.1.0846

vim-patch:8.1.{0846,0878,0884,2358},8.2.{0305,0352,0687,3797}
This commit is contained in:
zeertzjq
2022-02-04 09:48:48 +08:00
committed by GitHub
12 changed files with 109 additions and 47 deletions

View File

@@ -3543,24 +3543,25 @@ has({feature}) Returns 1 if {feature} is supported, 0 otherwise. The
:if has("win32") :if has("win32")
< *feature-list* < *feature-list*
List of supported pseudo-feature names: List of supported pseudo-feature names:
acl |ACL| support acl |ACL| support.
bsd BSD system (not macOS, use "mac" for that). bsd BSD system (not macOS, use "mac" for that).
iconv Can use |iconv()| for conversion.
+shellslash Can use backslashes in filenames (Windows)
clipboard |clipboard| provider is available. clipboard |clipboard| provider is available.
fname_case Case in file names matters (for Darwin and MS-Windows fname_case Case in file names matters (for Darwin and MS-Windows
this is not present). this is not present).
iconv Can use |iconv()| for conversion.
linux Linux system.
mac MacOS system. mac MacOS system.
nvim This is Nvim. nvim This is Nvim.
python3 Legacy Vim |python3| interface. |has-python| python3 Legacy Vim |python3| interface. |has-python|
pythonx Legacy Vim |python_x| interface. |has-pythonx| pythonx Legacy Vim |python_x| interface. |has-pythonx|
ttyin input is a terminal (tty) sun SunOS system.
ttyout output is a terminal (tty) ttyin input is a terminal (tty).
ttyout output is a terminal (tty).
unix Unix system. unix Unix system.
*vim_starting* True during |startup|. *vim_starting* True during |startup|.
win32 Windows system (32 or 64 bit). win32 Windows system (32 or 64 bit).
win64 Windows system (64 bit). win64 Windows system (64 bit).
wsl WSL (Windows Subsystem for Linux) system wsl WSL (Windows Subsystem for Linux) system.
*has-patch* *has-patch*
3. Vim patch. For example the "patch123" feature means that 3. Vim patch. For example the "patch123" feature means that
@@ -4347,6 +4348,9 @@ line({expr} [, {winid}]) *line()*
line("'t") line number of mark t line("'t") line number of mark t
line("'" . marker) line number of mark marker line("'" . marker) line number of mark marker
< <
To jump to the last known position when opening a file see
|last-position-jump|.
Can also be used as a |method|: > Can also be used as a |method|: >
GetValue()->line() GetValue()->line()
@@ -4912,8 +4916,10 @@ min({expr}) Return the minimum value of all items in {expr}.
< *mkdir()* *E739* < *mkdir()* *E739*
mkdir({name} [, {path} [, {prot}]]) mkdir({name} [, {path} [, {prot}]])
Create directory {name}. Create directory {name}.
If {path} is "p" then intermediate directories are created as If {path} is "p" then intermediate directories are created as
necessary. Otherwise it must be "". necessary. Otherwise it must be "".
If {prot} is given it is used to set the protection bits of If {prot} is given it is used to set the protection bits of
the new directory. The default is 0o755 (rwxr-xr-x: r/w for the new directory. The default is 0o755 (rwxr-xr-x: r/w for
the user, readable for others). Use 0o700 to make it the user, readable for others). Use 0o700 to make it
@@ -4922,6 +4928,7 @@ mkdir({name} [, {path} [, {prot}]])
{prot} is applied for all parts of {name}. Thus if you create {prot} is applied for all parts of {name}. Thus if you create
/tmp/foo/bar then /tmp/foo will be created with 0o700. Example: > /tmp/foo/bar then /tmp/foo will be created with 0o700. Example: >
:call mkdir($HOME . "/tmp/foo/bar", "p", 0o700) :call mkdir($HOME . "/tmp/foo/bar", "p", 0o700)
< This function is not available in the |sandbox|. < This function is not available in the |sandbox|.
If you try to create an existing directory with {path} set to If you try to create an existing directory with {path} set to
@@ -5758,8 +5765,10 @@ remove({list}, {idx} [, {end}]) *remove()*
Example: > Example: >
:echo "last item: " . remove(mylist, -1) :echo "last item: " . remove(mylist, -1)
:call remove(mylist, 0, 9) :call remove(mylist, 0, 9)
<
Use |delete()| to remove a file.
< Can also be used as a |method|: > Can also be used as a |method|: >
mylist->remove(idx) mylist->remove(idx)
remove({blob}, {idx} [, {end}]) remove({blob}, {idx} [, {end}])
@@ -5779,8 +5788,6 @@ remove({dict}, {key})
:echo "removed " . remove(dict, "one") :echo "removed " . remove(dict, "one")
< If there is no {key} in {dict} this is an error. < If there is no {key} in {dict} this is an error.
Use |delete()| to remove a file.
rename({from}, {to}) *rename()* rename({from}, {to}) *rename()*
Rename the file by the name {from} to the name {to}. This Rename the file by the name {from} to the name {to}. This
should also work to move files across file systems. The should also work to move files across file systems. The

View File

@@ -676,7 +676,7 @@ similar to -1. >
:let otherblob = myblob[:] " make a copy of the Blob :let otherblob = myblob[:] " make a copy of the Blob
If the first index is beyond the last byte of the Blob or the second byte is If the first index is beyond the last byte of the Blob or the second byte is
before the first byte, the result is an empty Blob. There is no error before the first index, the result is an empty Blob. There is no error
message. message.
If the second index is equal to or greater than the length of the Blob the If the second index is equal to or greater than the length of the Blob the

View File

@@ -27,8 +27,7 @@ depends on the 'shortmess' option.
Clear messages, keeping only the {count} most Clear messages, keeping only the {count} most
recent ones. recent ones.
The number of remembered messages is fixed at 20 for the tiny version and 200 The number of remembered messages is fixed at 200.
for other versions.
*g<* *g<*
The "g<" command can be used to see the last page of previous command output. The "g<" command can be used to see the last page of previous command output.

View File

@@ -4419,6 +4419,12 @@ static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr)
#if defined(BSD) && !defined(__APPLE__) #if defined(BSD) && !defined(__APPLE__)
"bsd", "bsd",
#endif #endif
#ifdef __linux__
"linux",
#endif
#ifdef SUN_SYSTEM
"sun",
#endif
#ifdef UNIX #ifdef UNIX
"unix", "unix",
#endif #endif

View File

@@ -63,6 +63,15 @@ func CheckUnix()
endif endif
endfunc endfunc
" Command to check for not running on a BSD system.
" TODO: using this checks should not be needed
command CheckNotBSD call CheckNotBSD()
func CheckNotBSD()
if has('bsd')
throw 'Skipped: does not work on BSD'
endif
endfunc
" Command to check that making screendumps is supported. " Command to check that making screendumps is supported.
" Caller must source screendump.vim " Caller must source screendump.vim
command CheckScreendump call CheckScreendump() command CheckScreendump call CheckScreendump()

View File

@@ -6,7 +6,6 @@
source test_charsearch_utf8.vim source test_charsearch_utf8.vim
source test_expr_utf8.vim source test_expr_utf8.vim
source test_matchadd_conceal_utf8.vim
source test_mksession_utf8.vim source test_mksession_utf8.vim
source test_regexp_utf8.vim source test_regexp_utf8.vim
source test_source_utf8.vim source test_source_utf8.vim

View File

@@ -1377,6 +1377,36 @@ func Test_func_exists_on_reload()
delfunc ExistingFunction delfunc ExistingFunction
endfunc endfunc
func Test_platform_name()
" The system matches at most only one name.
let names = ['amiga', 'beos', 'bsd', 'hpux', 'linux', 'mac', 'qnx', 'sun', 'vms', 'win32', 'win32unix']
call assert_inrange(0, 1, len(filter(copy(names), 'has(v:val)')))
" Is Unix?
call assert_equal(has('beos'), has('beos') && has('unix'))
call assert_equal(has('bsd'), has('bsd') && has('unix'))
call assert_equal(has('hpux'), has('hpux') && has('unix'))
call assert_equal(has('linux'), has('linux') && has('unix'))
call assert_equal(has('mac'), has('mac') && has('unix'))
call assert_equal(has('qnx'), has('qnx') && has('unix'))
call assert_equal(has('sun'), has('sun') && has('unix'))
call assert_equal(has('win32'), has('win32') && !has('unix'))
call assert_equal(has('win32unix'), has('win32unix') && has('unix'))
if has('unix') && executable('uname')
let uname = system('uname')
call assert_equal(uname =~? 'BeOS', has('beos'))
" GNU userland on BSD kernels (e.g., GNU/kFreeBSD) don't have BSD defined
call assert_equal(uname =~? '\%(GNU/k\w\+\)\@<!BSD\|DragonFly', has('bsd'))
call assert_equal(uname =~? 'HP-UX', has('hpux'))
call assert_equal(uname =~? 'Linux', has('linux'))
call assert_equal(uname =~? 'Darwin', has('mac'))
call assert_equal(uname =~? 'QNX', has('qnx'))
call assert_equal(uname =~? 'SunOS', has('sun'))
call assert_equal(uname =~? 'CYGWIN\|MSYS', has('win32unix'))
endif
endfunc
sandbox function Fsandbox() sandbox function Fsandbox()
normal ix normal ix
endfunc endfunc
@@ -1519,7 +1549,17 @@ func Test_libcall_libcallnr()
let libc = 'msvcrt.dll' let libc = 'msvcrt.dll'
elseif has('mac') elseif has('mac')
let libc = 'libSystem.B.dylib' let libc = 'libSystem.B.dylib'
elseif system('uname -s') =~ 'SunOS' elseif executable('ldd')
let libc = matchstr(split(system('ldd ' . GetVimProg())), '/libc\.so\>')
endif
if get(l:, 'libc', '') ==# ''
" On Unix, libc.so can be in various places.
if has('linux')
" There is not documented but regarding the 1st argument of glibc's
" dlopen an empty string and nullptr are equivalent, so using an empty
" string for the 1st argument of libcall allows to call functions.
let libc = ''
elseif has('sun')
" Set the path to libc.so according to the architecture. " Set the path to libc.so according to the architecture.
let test_bits = system('file ' . GetVimProg()) let test_bits = system('file ' . GetVimProg())
let test_arch = system('uname -p') let test_arch = system('uname -p')
@@ -1530,13 +1570,10 @@ func Test_libcall_libcallnr()
else else
let libc = '/usr/lib/libc.so' let libc = '/usr/lib/libc.so'
endif endif
elseif system('uname -s') =~ 'OpenBSD'
let libc = 'libc.so'
else else
" On Unix, libc.so can be in various places. " Unfortunately skip this test until a good way is found.
" Interestingly, using an empty string for the 1st argument of libcall return
" allows to call functions from libc which is not documented. endif
let libc = ''
endif endif
if has('win32') if has('win32')

View File

@@ -284,10 +284,10 @@ func Test_relativenumber_colors()
" Default colors " Default colors
call VerifyScreenDump(buf, 'Test_relnr_colors_1', {}) call VerifyScreenDump(buf, 'Test_relnr_colors_1', {})
call term_sendkeys(buf, ":hi LineNrAbove ctermfg=blue\<CR>") call term_sendkeys(buf, ":hi LineNrAbove ctermfg=blue\<CR>:\<CR>")
call VerifyScreenDump(buf, 'Test_relnr_colors_2', {}) call VerifyScreenDump(buf, 'Test_relnr_colors_2', {})
call term_sendkeys(buf, ":hi LineNrBelow ctermfg=green\<CR>") call term_sendkeys(buf, ":hi LineNrBelow ctermfg=green\<CR>:\<CR>")
call VerifyScreenDump(buf, 'Test_relnr_colors_3', {}) call VerifyScreenDump(buf, 'Test_relnr_colors_3', {})
call term_sendkeys(buf, ":hi clear LineNrAbove\<CR>") call term_sendkeys(buf, ":hi clear LineNrAbove\<CR>")

View File

@@ -1914,6 +1914,7 @@ func Test_switchbuf()
" If opening a file changes 'switchbuf', then the new value should be " If opening a file changes 'switchbuf', then the new value should be
" retained. " retained.
set modeline&vim
call writefile(["vim: switchbuf=split"], 'Xqftestfile1') call writefile(["vim: switchbuf=split"], 'Xqftestfile1')
enew | only enew | only
set switchbuf&vim set switchbuf&vim

View File

@@ -1,4 +1,5 @@
" Test the :source! command " Test the :source! command
source check.vim
func Test_source_utf8() func Test_source_utf8()
" check that sourcing a script with 0x80 as second byte works " check that sourcing a script with 0x80 as second byte works

View File

@@ -86,6 +86,9 @@ endfunc
" test that g~ap changes one paragraph only. " test that g~ap changes one paragraph only.
func Test_gap() func Test_gap()
new new
call feedkeys("iabcd\n\ndefggg0g~ap", "tx") " setup text
call feedkeys("iabcd\<cr>\<cr>defg", "tx")
" modify only first line
call feedkeys("gg0g~ap", "tx")
call assert_equal(["ABCD", "", "defg"], getline(1,3)) call assert_equal(["ABCD", "", "defg"], getline(1,3))
endfunc endfunc

View File

@@ -43,7 +43,7 @@ func Test_writefile_fails_gently()
endfunc endfunc
func Test_writefile_fails_conversion() func Test_writefile_fails_conversion()
if !has('iconv') || system('uname -s') =~ 'SunOS' if !has('iconv') || has('sun')
return return
endif endif
" Without a backup file the write won't happen if there is a conversion " Without a backup file the write won't happen if there is a conversion