Merge #11572 from janlazo/vim-8.2.0015

vim-patch:8.2.{15,18}
This commit is contained in:
Justin M. Keyes 2019-12-19 12:25:25 -08:00 committed by GitHub
commit 486ddb6eb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 500 additions and 5 deletions

View File

@ -3772,7 +3772,7 @@ int do_join(size_t count,
curr = skipwhite(curr);
if (*curr != NUL
&& *curr != ')'
&& currsize != 0
&& sumsize != 0
&& endcurr1 != TAB
&& (!has_format_option(FO_MBYTE_JOIN)
|| (utf_ptr2char(curr) < 0x100 && endcurr1 < 0x100))

View File

@ -66,6 +66,7 @@ func Test_curswant_with_cursorline()
endfunc
func Test_screenpos()
throw 'skipped: TODO: '
rightbelow new
rightbelow 20vsplit
call setline(1, ["\tsome text", "long wrapping line here", "next line"])

View File

@ -54,3 +54,388 @@ func Test_join_marks()
call assert_equal([0, 4, 67, 0], getpos("']"))
enew!
endfunc
" Test for joining lines and marks in them
" in compatible and nocompatible modes
" and with 'joinspaces' set or not
" and with 'cpoptions' flag 'j' set or not
func Test_join_spaces_marks()
new
" Text used for the test
insert
asdfasdf.
asdf
asdfasdf.
asdf
asdfasdf.
asdf
asdfasdf.
asdf
asdfasdf.
asdf
asdfasdf.
asdf
asdfasdf.
asdf
asdfasdf
asdf
asdfasdf
asdf
asdfasdf
asdf
asdfasdf
asdf
asdfasdf
asdf
asdfasdf
asdf
asdfasdf
asdf
zx cvn.
as dfg?
hjkl iop!
ert
zx cvn.
as dfg?
hjkl iop!
ert
.
let text = getline(1, '$')
normal gg
set nojoinspaces
set cpoptions-=j
normal JjJjJjJjJjJjJjJjJjJjJjJjJjJ
normal j05lmx
normal 2j06lmy
normal 2k4Jy3l$p
normal `xyl$p
normal `yy2l$p
" set cpoptions+=j
normal j05lmx
normal 2j06lmy
normal 2k4Jy3l$p
normal `xyl$p
normal `yy2l$p
" Expected output
let expected =<< trim [DATA]
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf asdf
asdfasdf asdf
asdfasdf asdf
asdfasdf asdf
asdfasdf asdf
asdfasdf asdf
asdfasdf asdf
zx cvn. as dfg? hjkl iop! ert ernop
zx cvn. as dfg? hjkl iop! ert ernop
[DATA]
call assert_equal(expected, getline(1, '$'))
throw 'skipped: Nvim does not support "set compatible" or "set cpoptions+=j"'
enew!
call append(0, text)
normal gg
set cpoptions-=j
set joinspaces
normal JjJjJjJjJjJjJjJjJjJjJjJjJjJ
normal j05lmx
normal 2j06lmy
normal 2k4Jy3l$p
normal `xyl$p
normal `yy2l$p
set cpoptions+=j
normal j05lmx
normal 2j06lmy
normal 2k4Jy3l$p
normal `xyl$p
normal `yy2l$p
" Expected output
let expected =<< trim [DATA]
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf asdf
asdfasdf asdf
asdfasdf asdf
asdfasdf asdf
asdfasdf asdf
asdfasdf asdf
asdfasdf asdf
zx cvn. as dfg? hjkl iop! ert enop
zx cvn. as dfg? hjkl iop! ert ernop
[DATA]
call assert_equal(expected, getline(1, '$'))
enew!
call append(0, text)
normal gg
set cpoptions-=j
set nojoinspaces
set compatible
normal JjJjJjJjJjJjJjJjJjJjJjJjJjJ
normal j4Jy3l$pjdG
" Expected output
let expected =<< trim [DATA]
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf asdf
asdfasdf asdf
asdfasdf asdf
asdfasdf asdf
asdfasdf asdf
asdfasdf asdf
asdfasdf asdf
zx cvn. as dfg? hjkl iop! ert a
[DATA]
call assert_equal(expected, getline(1, '$'))
set nocompatible
set cpoptions&vim
set joinspaces&vim
close!
endfunc
" Test for joining lines with comments
func Test_join_lines_with_comments()
new
" Text used by the test
insert
{
/*
* Make sure the previous comment leader is not removed.
*/
/*
* Make sure the previous comment leader is not removed.
*/
// Should the next comment leader be left alone?
// Yes.
// Should the next comment leader be left alone?
// Yes.
/* Here the comment leader should be left intact. */
// And so should this one.
/* Here the comment leader should be left intact. */
// And so should this one.
if (condition) // Remove the next comment leader!
// OK, I will.
action();
if (condition) // Remove the next comment leader!
// OK, I will.
action();
}
.
call cursor(2, 1)
set comments=s1:/*,mb:*,ex:*/,://
set nojoinspaces fo=j
set backspace=eol,start
.,+3join
exe "normal j4J\<CR>"
.,+2join
exe "normal j3J\<CR>"
.,+2join
exe "normal j3J\<CR>"
.,+2join
exe "normal jj3J\<CR>"
" Expected output
let expected =<< trim [CODE]
{
/* Make sure the previous comment leader is not removed. */
/* Make sure the previous comment leader is not removed. */
// Should the next comment leader be left alone? Yes.
// Should the next comment leader be left alone? Yes.
/* Here the comment leader should be left intact. */ // And so should this one.
/* Here the comment leader should be left intact. */ // And so should this one.
if (condition) // Remove the next comment leader! OK, I will.
action();
if (condition) // Remove the next comment leader! OK, I will.
action();
}
[CODE]
call assert_equal(expected, getline(1, '$'))
set comments&vim
set joinspaces&vim
set fo&vim
set backspace&vim
close!
endfunc
" Test for joining lines with different comment leaders
func Test_join_comments_2()
new
insert
{
/*
* Make sure the previous comment leader is not removed.
*/
/*
* Make sure the previous comment leader is not removed.
*/
/* List:
* - item1
* foo bar baz
* foo bar baz
* - item2
* foo bar baz
* foo bar baz
*/
/* List:
* - item1
* foo bar baz
* foo bar baz
* - item2
* foo bar baz
* foo bar baz
*/
// Should the next comment leader be left alone?
// Yes.
// Should the next comment leader be left alone?
// Yes.
/* Here the comment leader should be left intact. */
// And so should this one.
/* Here the comment leader should be left intact. */
// And so should this one.
if (condition) // Remove the next comment leader!
// OK, I will.
action();
if (condition) // Remove the next comment leader!
// OK, I will.
action();
int i = 7 /* foo *// 3
// comment
;
int i = 7 /* foo *// 3
// comment
;
># Note that the last character of the ending comment leader (left angle
# bracket) is a comment leader itself. Make sure that this comment leader is
# not removed from the next line #<
< On this line a new comment is opened which spans 2 lines. This comment should
< retain its comment leader.
># Note that the last character of the ending comment leader (left angle
# bracket) is a comment leader itself. Make sure that this comment leader is
# not removed from the next line #<
< On this line a new comment is opened which spans 2 lines. This comment should
< retain its comment leader.
}
.
call cursor(2, 1)
set comments=sO:*\ -,mO:*\ \ ,exO:*/
set comments+=s1:/*,mb:*,ex:*/,://
set comments+=s1:>#,mb:#,ex:#<,:<
set cpoptions-=j joinspaces fo=j
set backspace=eol,start
.,+3join
exe "normal j4J\<CR>"
.,+8join
exe "normal j9J\<CR>"
.,+2join
exe "normal j3J\<CR>"
.,+2join
exe "normal j3J\<CR>"
.,+2join
exe "normal jj3J\<CR>j"
.,+2join
exe "normal jj3J\<CR>j"
.,+5join
exe "normal j6J\<CR>"
exe "normal oSome code!\<CR>// Make sure backspacing does not remove this comment leader.\<Esc>0i\<C-H>\<Esc>"
" Expected output
let expected =<< trim [CODE]
{
/* Make sure the previous comment leader is not removed. */
/* Make sure the previous comment leader is not removed. */
/* List: item1 foo bar baz foo bar baz item2 foo bar baz foo bar baz */
/* List: item1 foo bar baz foo bar baz item2 foo bar baz foo bar baz */
// Should the next comment leader be left alone? Yes.
// Should the next comment leader be left alone? Yes.
/* Here the comment leader should be left intact. */ // And so should this one.
/* Here the comment leader should be left intact. */ // And so should this one.
if (condition) // Remove the next comment leader! OK, I will.
action();
if (condition) // Remove the next comment leader! OK, I will.
action();
int i = 7 /* foo *// 3 // comment
;
int i = 7 /* foo *// 3 // comment
;
># Note that the last character of the ending comment leader (left angle bracket) is a comment leader itself. Make sure that this comment leader is not removed from the next line #< < On this line a new comment is opened which spans 2 lines. This comment should retain its comment leader.
># Note that the last character of the ending comment leader (left angle bracket) is a comment leader itself. Make sure that this comment leader is not removed from the next line #< < On this line a new comment is opened which spans 2 lines. This comment should retain its comment leader.
Some code!// Make sure backspacing does not remove this comment leader.
}
[CODE]
call assert_equal(expected, getline(1, '$'))
close!
endfunc
func Test_join_lines()
new
call setline(1, ['a', 'b', '', 'c', 'd'])
%join
call assert_equal('a b c d', getline(1))
call setline(1, ['a', 'b', '', 'c', 'd'])
normal 5J
call assert_equal('a b c d', getline(1))
bwipe!
endfunc

View File

@ -5,12 +5,30 @@ func Test_modeline_invalid()
call writefile(['vi:0', 'nothing'], 'Xmodeline')
let modeline = &modeline
set modeline
call assert_fails('set Xmodeline', 'E518:')
call assert_fails('split Xmodeline', 'E518:')
" Missing end colon (ignored).
call writefile(['// vim: set ts=2'], 'Xmodeline')
edit Xmodeline_version
call assert_equal(8, &ts)
bwipe!
" Missing colon at beginning (ignored).
call writefile(['// vim set ts=2:'], 'Xmodeline')
edit Xmodeline_version
call assert_equal(8, &ts)
bwipe!
" Missing space after vim (ignored).
call writefile(['// vim:ts=2:'], 'Xmodeline')
edit Xmodeline_version
call assert_equal(8, &ts)
bwipe!
let &modeline = modeline
bwipe!
call delete('Xmodeline')
endfunc
endfunc
func Test_modeline_filetype()
call writefile(['vim: set ft=c :', 'nothing'], 'Xmodeline_filetype')
@ -60,8 +78,99 @@ func Test_modeline_keymap()
set keymap= iminsert=0 imsearch=-1
endfunc
func Test_modeline_version()
let modeline = &modeline
set modeline
" Test with vim:{vers}: (version {vers} or later).
call writefile(['// vim' .. v:version .. ': ts=2:'], 'Xmodeline_version')
edit Xmodeline_version
call assert_equal(2, &ts)
bwipe!
call writefile(['// vim' .. (v:version - 100) .. ': ts=2:'], 'Xmodeline_version')
edit Xmodeline_version
call assert_equal(2, &ts)
bwipe!
call writefile(['// vim' .. (v:version + 100) .. ': ts=2:'], 'Xmodeline_version')
edit Xmodeline_version
call assert_equal(8, &ts)
bw!
" Test with vim>{vers}: (version after {vers}).
call writefile(['// vim>' .. v:version .. ': ts=2:'], 'Xmodeline_version')
edit Xmodeline_version
call assert_equal(8, &ts)
bwipe!
call writefile(['// vim>' .. (v:version - 100) .. ': ts=2:'], 'Xmodeline_version')
edit Xmodeline_version
call assert_equal(2, &ts)
bwipe!
call writefile(['// vim>' .. (v:version + 100) .. ': ts=2:'], 'Xmodeline_version')
edit Xmodeline_version
call assert_equal(8, &ts)
bwipe!
" Test with vim<{vers}: (version before {vers}).
call writefile(['// vim<' .. v:version .. ': ts=2:'], 'Xmodeline_version')
edit Xmodeline_version
call assert_equal(8, &ts)
bwipe!
call writefile(['// vim<' .. (v:version - 100) .. ': ts=2:'], 'Xmodeline_version')
edit Xmodeline_version
call assert_equal(8, &ts)
bwipe!
call writefile(['// vim<' .. (v:version + 100) .. ': ts=2:'], 'Xmodeline_version')
edit Xmodeline_version
call assert_equal(2, &ts)
bwipe!
" Test with vim={vers}: (version {vers} only).
call writefile(['// vim=' .. v:version .. ': ts=2:'], 'Xmodeline_version')
edit Xmodeline_version
call assert_equal(2, &ts)
bwipe!
call writefile(['// vim=' .. (v:version - 100) .. ': ts=2:'], 'Xmodeline_version')
edit Xmodeline_version
call assert_equal(8, &ts)
bwipe!
call writefile(['// vim=' .. (v:version + 100) .. ': ts=2:'], 'Xmodeline_version')
edit Xmodeline_version
call assert_equal(8, &ts)
bwipe!
let &modeline = modeline
call delete('Xmodeline_version')
endfunc
func Test_modeline_colon()
let modeline = &modeline
set modeline
call writefile(['// vim: set showbreak=\: ts=2: sw=2'], 'Xmodeline_colon')
edit Xmodeline_colon
" backlash colon should become colon.
call assert_equal(':', &showbreak)
" 'ts' should be set.
" 'sw' should be ignored because it is after the end colon.
call assert_equal(2, &ts)
call assert_equal(8, &sw)
let &modeline = modeline
call delete('Xmodeline_colon')
endfunc
func s:modeline_fails(what, text, error)
if !exists('+' . a:what)
if !exists('+' .. a:what)
return
endif
let fname = "Xmodeline_fails_" . a:what
@ -119,7 +228,7 @@ func Test_modeline_fails_always()
call s:modeline_fails('mkspellmem', 'mkspellmem=Something()', 'E520:')
call s:modeline_fails('mzschemedll', 'mzschemedll=Something()', 'E520:')
call s:modeline_fails('mzschemegcdll', 'mzschemegcdll=Something()', 'E520:')
call s:modeline_fails('modelineexpr', 'modelineexpr=Something()', 'E520:')
call s:modeline_fails('modelineexpr', 'modelineexpr', 'E520:')
call s:modeline_fails('omnifunc', 'omnifunc=Something()', 'E520:')
call s:modeline_fails('operatorfunc', 'operatorfunc=Something()', 'E520:')
call s:modeline_fails('perldll', 'perldll=Something()', 'E520:')