Merge pull request #15580 from seandewar/vim-8.2.3378

vim-patch:8.2.{3378,3379,3384,3386,3398,3400}
This commit is contained in:
Jan Edmund Lazo 2021-09-17 09:39:36 -04:00 committed by GitHub
commit 1ec3d37192
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 238 additions and 90 deletions

View File

@ -435,6 +435,15 @@ chance that a normal word like "lex:" is caught. There is one exception:
version 3.0). Using "ex:" at the start of the line will be ignored (this
could be short for "example:").
If the modeline is disabled within a modeline, subsequent modelines will be
ignored. This is to allow turning off modeline on a per-file basis. This is
useful when a line looks like a modeline but isn't. For example, it would be
good to start a YAML file containing strings like "vim:" with
# vim: nomodeline ~
so as to avoid modeline misdetection. Following options on the same line
after modeline deactivation, if any, are still evaluated (but you would
normally not have any).
*modeline-local*
The options are set like with ":setlocal": The new value only applies to the
buffer and window that contain the file. Although it's possible to set global

View File

@ -166,9 +166,13 @@ g8 Print the hex values of the bytes used in the
If the mark is "=", a line of dashes is printed
around the current line.
:[range]z#[+-^.=][count] *:z#*
Like ":z", but number the lines.
{not in all versions of Vi, not with these arguments}
*:z!*
:[range]z![+-^.=][count]
Like ":z:", but when [count] is not specified, it
defaults to the Vim window height minus one.
:[range]z[!]#[+-^.=][count] *:z#*
Like ":z" or ":z!", but number the lines.
*:=*
:= [flags] Print the last line number.

View File

@ -5261,15 +5261,16 @@ void do_modelines(int flags)
}
entered++;
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count && lnum <= nmlines;
lnum++) {
for (lnum = 1; curbuf->b_p_ml && lnum <= curbuf->b_ml.ml_line_count
&& lnum <= nmlines; lnum++) {
if (chk_modeline(lnum, flags) == FAIL) {
nmlines = 0;
}
}
for (lnum = curbuf->b_ml.ml_line_count; lnum > 0 && lnum > nmlines
&& lnum > curbuf->b_ml.ml_line_count - nmlines; lnum--) {
for (lnum = curbuf->b_ml.ml_line_count; curbuf->b_p_ml && lnum > 0
&& lnum > nmlines && lnum > curbuf->b_ml.ml_line_count - nmlines;
lnum--) {
if (chk_modeline(lnum, flags) == FAIL) {
nmlines = 0;
}

View File

@ -3088,7 +3088,7 @@ void ex_z(exarg_T *eap)
// Vi compatible: ":z!" uses display height, without a count uses
// 'scroll'
if (eap->forceit) {
bigness = curwin->w_height_inner;
bigness = Rows - 1;
} else if (ONE_WINDOW) {
bigness = curwin->w_p_scr * 2;
} else {

View File

@ -3271,7 +3271,7 @@ module.cmds = {
},
{
command='z',
flags=bit.bor(RANGE, WHOLEFOLD, EXTRA, FLAGS, TRLBAR, CMDWIN),
flags=bit.bor(RANGE, WHOLEFOLD, BANG, EXTRA, FLAGS, TRLBAR, CMDWIN),
addr_type='ADDR_LINES',
func='ex_z',
},

View File

@ -3230,7 +3230,7 @@ const char * set_one_cmd_context(expand_T *xp, const char *buff)
}
}
}
// Check for user names
// Check for user names.
if (*xp->xp_pattern == '~') {
for (p = (const char *)xp->xp_pattern + 1; *p != NUL && *p != '/'; p++) {
}

View File

@ -474,6 +474,7 @@ int get_breakindent_win(win_T *wp, char_u *line)
};
if (regmatch.regprog != NULL) {
regmatch.rm_ic = false;
if (vim_regexec(&regmatch, line, 0)) {
if (wp->w_briopt_list > 0) {
bri += wp->w_briopt_list;

View File

@ -7,6 +7,10 @@ func Test_complete_tab()
call writefile(['testfile'], 'Xtestfile')
call feedkeys(":e Xtestf\t\r", "tx")
call assert_equal('testfile', getline(1))
" Pressing <Tab> after '%' completes the current file, also on MS-Windows
call feedkeys(":e %\t\r", "tx")
call assert_equal('e Xtestfile', @:)
call delete('Xtestfile')
endfunc

View File

@ -16,8 +16,9 @@ func Test_z()
call assert_equal(23, line('.'))
let a = execute('20z+3')
" FIXME: I would expect the same result as '20z3' but it
" gives "\n21\n22\n23" instead. Bug in Vim or in ":help :z"?
" FIXME: I would expect the same result as '20z3' since 'help z'
" says: Specifying no mark at all is the same as "+".
" However it " gives "\n21\n22\n23" instead. Bug in Vim or in ":help :z"?
"call assert_equal("\n20\n21\n22", a)
"call assert_equal(22, line('.'))
@ -55,19 +56,48 @@ func Test_z()
call assert_equal(100, line('.'))
let a = execute('20z-1000')
call assert_match("^\n1\n2\n.*\n19\n20$", a)
call assert_equal(20, line('.'))
let a = execute('20z=1000')
call assert_match("^\n1\n.*\n-\\+\n20\n-\\\+\n.*\n100$", a)
call assert_equal(20, line('.'))
" Tests with multiple windows.
5split
call setline(1, range(1, 100))
" Without a count, the number line is window height - 3.
let a = execute('20z')
call assert_equal("\n20\n21", a)
call assert_equal(21, line('.'))
" If window height - 3 is less than 1, it should be clamped to 1.
resize 2
let a = execute('20z')
call assert_equal("\n20", a)
call assert_equal(20, line('.'))
call assert_fails('20z=a', 'E144:')
set window& scroll&
bw!
endfunc
" :z! is the same as :z but count uses the Vim window height when not specified.
func Test_z_bang()
4split
call setline(1, range(1, 20))
let a = execute('10z!')
call assert_equal("\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20", a)
let a = execute('10z!#')
call assert_equal("\n 10 10\n 11 11\n 12 12\n 13 13\n 14 14\n 15 15\n 16 16\n 17 17\n 18 18\n 19 19\n 20 20", a)
let a = execute('10z!3')
call assert_equal("\n10\n11\n12", a)
%bwipe!
endfunc
func Test_z_bug()
" This used to access invalid memory as a result of an integer overflow
" and freeze vim.

View File

@ -280,3 +280,13 @@ func Test_modeline_fails_modelineexpr()
call s:modeline_fails('tabline', 'tabline=Something()', 'E992:')
call s:modeline_fails('titlestring', 'titlestring=Something()', 'E992:')
endfunc
func Test_modeline_disable()
set modeline
call writefile(['vim: sw=2', 'vim: nomodeline', 'vim: sw=3'], 'Xmodeline_disable')
edit Xmodeline_disable
call assert_equal(2, &sw)
call delete('Xmodeline_disable')
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@ -89,101 +89,109 @@ endfunc
" Tests for string and html text objects
func Test_string_html_objects()
enew!
let t = '"wo\"rd\\" foo'
put =t
normal! da"
call assert_equal('foo', getline('.'))
" Nvim only supports set encoding=utf-8
" for e in ['utf-8', 'latin1', 'cp932']
for e in ['utf-8']
enew!
exe 'set enc=' .. e
let t = "'foo' 'bar' 'piep'"
put =t
normal! 0va'a'rx
call assert_equal("xxxxxxxxxxxx'piep'", getline('.'))
let t = '"wo\"rd\\" foo'
put =t
normal! da"
call assert_equal('foo', getline('.'), e)
let t = "bla bla `quote` blah"
put =t
normal! 02f`da`
call assert_equal("bla bla blah", getline('.'))
let t = "'foo' 'bar' 'piep'"
put =t
normal! 0va'a'rx
call assert_equal("xxxxxxxxxxxx'piep'", getline('.'), e)
let t = 'out " in "noXno"'
put =t
normal! 0fXdi"
call assert_equal('out " in ""', getline('.'))
let t = "bla bla `quote` blah"
put =t
normal! 02f`da`
call assert_equal("bla bla blah", getline('.'), e)
let t = "\"'\" 'blah' rep 'buh'"
put =t
normal! 03f'vi'ry
call assert_equal("\"'\" 'blah'yyyyy'buh'", getline('.'))
let t = 'out " in "noXno"'
put =t
normal! 0fXdi"
call assert_equal('out " in ""', getline('.'), e)
set quoteescape=+*-
let t = "bla `s*`d-`+++`l**` b`la"
put =t
normal! di`
call assert_equal("bla `` b`la", getline('.'))
let t = "\"'\" 'blah' rep 'buh'"
put =t
normal! 03f'vi'ry
call assert_equal("\"'\" 'blah'yyyyy'buh'", getline('.'), e)
let t = 'voo "nah" sdf " asdf" sdf " sdf" sd'
put =t
normal! $F"va"oha"i"rz
call assert_equal('voo "zzzzzzzzzzzzzzzzzzzzzzzzzzzzsd', getline('.'))
set quoteescape=+*-
let t = "bla `s*`d-`+++`l**` b`la"
put =t
normal! di`
call assert_equal("bla `` b`la", getline('.'), e)
let t = "-<b>asdf<i>Xasdf</i>asdf</b>-"
put =t
normal! fXdit
call assert_equal('-<b>asdf<i></i>asdf</b>-', getline('.'))
let t = 'voo "nah" sdf " asdf" sdf " sdf" sd'
put =t
normal! $F"va"oha"i"rz
call assert_equal('voo "zzzzzzzzzzzzzzzzzzzzzzzzzzzzsd', getline('.'), e)
let t = "-<b>asdX<i>a<i />sdf</i>asdf</b>-"
put =t
normal! 0fXdit
call assert_equal('-<b></b>-', getline('.'))
let t = "-<b>asdf<i>Xasdf</i>asdf</b>-"
put =t
normal! fXdit
call assert_equal('-<b>asdf<i></i>asdf</b>-', getline('.'), e)
let t = "-<b>asdf<i>Xasdf</i>asdf</b>-"
put =t
normal! fXdat
call assert_equal('-<b>asdfasdf</b>-', getline('.'))
let t = "-<b>asdX<i>a<i />sdf</i>asdf</b>-"
put =t
normal! 0fXdit
call assert_equal('-<b></b>-', getline('.'), e)
let t = "-<b>asdX<i>as<b />df</i>asdf</b>-"
put =t
normal! 0fXdat
call assert_equal('--', getline('.'))
let t = "-<b>asdf<i>Xasdf</i>asdf</b>-"
put =t
normal! fXdat
call assert_equal('-<b>asdfasdf</b>-', getline('.'), e)
let t = "-<b>\ninnertext object\n</b>"
put =t
normal! dit
call assert_equal('-<b></b>', getline('.'))
let t = "-<b>asdX<i>as<b />df</i>asdf</b>-"
put =t
normal! 0fXdat
call assert_equal('--', getline('.'), e)
" copy the tag block from leading indentation before the start tag
let t = " <b>\ntext\n</b>"
$put =t
normal! 2kvaty
call assert_equal("<b>\ntext\n</b>", @")
let t = "-<b>\ninnertext object\n</b>"
put =t
normal! dit
call assert_equal('-<b></b>', getline('.'), e)
" copy the tag block from the end tag
let t = "<title>\nwelcome\n</title>"
$put =t
normal! $vaty
call assert_equal("<title>\nwelcome\n</title>", @")
" copy the tag block from leading indentation before the start tag
let t = " <b>\ntext\n</b>"
$put =t
normal! 2kvaty
call assert_equal("<b>\ntext\n</b>", @", e)
" copy the outer tag block from a tag without an end tag
let t = "<html>\n<title>welcome\n</html>"
$put =t
normal! k$vaty
call assert_equal("<html>\n<title>welcome\n</html>", @")
" copy the tag block from the end tag
let t = "<title>\nwelcome\n</title>"
$put =t
normal! $vaty
call assert_equal("<title>\nwelcome\n</title>", @", e)
" nested tag that has < in a different line from >
let t = "<div><div\n></div></div>"
$put =t
normal! k0vaty
call assert_equal("<div><div\n></div></div>", @")
" copy the outer tag block from a tag without an end tag
let t = "<html>\n<title>welcome\n</html>"
$put =t
normal! k$vaty
call assert_equal("<html>\n<title>welcome\n</html>", @", e)
" nested tag with attribute that has < in a different line from >
let t = "<div><div\nattr=\"attr\"\n></div></div>"
$put =t
normal! 2k0vaty
call assert_equal("<div><div\nattr=\"attr\"\n></div></div>", @")
" nested tag that has < in a different line from >
let t = "<div><div\n></div></div>"
$put =t
normal! k0vaty
call assert_equal("<div><div\n></div></div>", @", e)
set quoteescape&
enew!
" nested tag with attribute that has < in a different line from >
let t = "<div><div\nattr=\"attr\"\n></div></div>"
$put =t
normal! 2k0vaty
call assert_equal("<div><div\nattr=\"attr\"\n></div></div>", @", e)
set quoteescape&
endfor
set enc=utf-8
bwipe!
endfunc
func Test_empty_html_tag()
@ -333,3 +341,84 @@ func Test_sentence_with_cursor_on_delimiter()
%delete _
endfunc
" Test for quote (', " and `) textobjects
func Test_textobj_quote()
new
" Test for i" when cursor is in front of a quoted object
call append(0, 'foo "bar"')
norm! 1gg0di"
call assert_equal(['foo ""', ''], getline(1,'$'))
" Test for visually selecting an inner quote
%d
" extend visual selection from one quote to the next
call setline(1, 'color "red" color "blue"')
call cursor(1, 7)
normal v4li"y
call assert_equal('"red" color "blue', @")
" try to extend visual selection from one quote to a non-existing quote
call setline(1, 'color "red" color blue')
call cursor(1, 7)
call feedkeys('v4li"y', 'xt')
call assert_equal('"red"', @")
" try to extend visual selection from one quote to a next partial quote
call setline(1, 'color "red" color "blue')
call cursor(1, 7)
normal v4li"y
call assert_equal('"red" color ', @")
" select a quote backwards in visual mode
call cursor(1, 12)
normal vhi"y
call assert_equal('red" ', @")
call assert_equal(8, col('.'))
" select a quote backwards in visual mode from outside the quote
call cursor(1, 17)
normal v2hi"y
call assert_equal('red', @")
call assert_equal(8, col('.'))
" visually selecting a quote with 'selection' set to 'exclusive'
call setline(1, 'He said "How are you?"')
set selection=exclusive
normal 012lv2li"y
call assert_equal('How are you?', @")
set selection&
" try copy a quote object with a single quote in the line
call setline(1, "Smith's car")
call cursor(1, 6)
call assert_beeps("normal yi'")
call assert_beeps("normal 2lyi'")
" selecting space before and after a quoted string
call setline(1, "some 'special' string")
normal 0ya'
call assert_equal("'special' ", @")
call setline(1, "some 'special'string")
normal 0ya'
call assert_equal(" 'special'", @")
" quoted string with odd or even number of backslashes.
call setline(1, 'char *s = "foo\"bar"')
normal $hhyi"
call assert_equal('foo\"bar', @")
call setline(1, 'char *s = "foo\\"bar"')
normal $hhyi"
call assert_equal('bar', @")
call setline(1, 'char *s = "foo\\\"bar"')
normal $hhyi"
call assert_equal('foo\\\"bar', @")
call setline(1, 'char *s = "foo\\\\"bar"')
normal $hhyi"
call assert_equal('bar', @")
close!
endfunc
" vim: shiftwidth=2 sts=2 expandtab