Skip to content

Commit 1de54de

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 914798e + 2256c99 commit 1de54de

File tree

6 files changed

+127
-31
lines changed

6 files changed

+127
-31
lines changed

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,6 +2114,7 @@ test_arglist \
21142114
test_gui \
21152115
test_hardcopy \
21162116
test_help_tagjump \
2117+
test_hide \
21172118
test_history \
21182119
test_hlsearch \
21192120
test_increment \

src/ex_cmds.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ EX(CMD_highlight, "highlight", ex_highlight,
623623
BANG|EXTRA|TRLBAR|SBOXOK|CMDWIN,
624624
ADDR_LINES),
625625
EX(CMD_hide, "hide", ex_hide,
626-
BANG|RANGE|NOTADR|COUNT|EXTRA|NOTRLCOM,
626+
BANG|RANGE|NOTADR|COUNT|EXTRA|TRLBAR,
627627
ADDR_WINDOWS),
628628
EX(CMD_history, "history", ex_history,
629629
EXTRA|TRLBAR|CMDWIN,

src/ex_docmd.c

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5649,15 +5649,16 @@ find_nextcmd(char_u *p)
56495649
#endif
56505650

56515651
/*
5652-
* Check if *p is a separator between Ex commands.
5653-
* Return NULL if it isn't, (p + 1) if it is.
5652+
* Check if *p is a separator between Ex commands, skipping over white space.
5653+
* Return NULL if it isn't, the following character if it is.
56545654
*/
56555655
char_u *
56565656
check_nextcmd(char_u *p)
56575657
{
5658-
p = skipwhite(p);
5659-
if (*p == '|' || *p == '\n')
5660-
return (p + 1);
5658+
char_u *s = skipwhite(p);
5659+
5660+
if (*s == '|' || *s == '\n')
5661+
return (s + 1);
56615662
else
56625663
return NULL;
56635664
}
@@ -7589,38 +7590,32 @@ ex_all(exarg_T *eap)
75897590
static void
75907591
ex_hide(exarg_T *eap)
75917592
{
7592-
if (*eap->arg != NUL && check_nextcmd(eap->arg) == NULL)
7593-
eap->errmsg = e_invarg;
7594-
else
7595-
{
7596-
/* ":hide" or ":hide | cmd": hide current window */
7597-
eap->nextcmd = check_nextcmd(eap->arg);
7593+
/* ":hide" or ":hide | cmd": hide current window */
75987594
#ifdef FEAT_WINDOWS
7599-
if (!eap->skip)
7600-
{
7595+
if (!eap->skip)
7596+
{
76017597
# ifdef FEAT_GUI
7602-
need_mouse_correct = TRUE;
7598+
need_mouse_correct = TRUE;
76037599
# endif
7604-
if (eap->addr_count == 0)
7605-
win_close(curwin, FALSE); /* don't free buffer */
7606-
else
7607-
{
7608-
int winnr = 0;
7609-
win_T *win;
7600+
if (eap->addr_count == 0)
7601+
win_close(curwin, FALSE); /* don't free buffer */
7602+
else
7603+
{
7604+
int winnr = 0;
7605+
win_T *win;
76107606

7611-
FOR_ALL_WINDOWS(win)
7612-
{
7613-
winnr++;
7614-
if (winnr == eap->line2)
7615-
break;
7616-
}
7617-
if (win == NULL)
7618-
win = lastwin;
7619-
win_close(win, FALSE);
7607+
FOR_ALL_WINDOWS(win)
7608+
{
7609+
winnr++;
7610+
if (winnr == eap->line2)
7611+
break;
76207612
}
7613+
if (win == NULL)
7614+
win = lastwin;
7615+
win_close(win, FALSE);
76217616
}
7622-
#endif
76237617
}
7618+
#endif
76247619
}
76257620

76267621
/*

src/testdir/Make_all.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ NEW_TESTS = test_arglist.res \
156156
test_gn.res \
157157
test_gui.res \
158158
test_hardcopy.res \
159+
test_hide.res \
159160
test_history.res \
160161
test_hlsearch.res \
161162
test_increment.res \

src/testdir/test_hide.vim

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
" Tests for :hide command/modifier and 'hidden' option
2+
3+
function SetUp()
4+
let s:save_hidden = &hidden
5+
let s:save_bufhidden = &bufhidden
6+
let s:save_autowrite = &autowrite
7+
set nohidden
8+
set bufhidden=
9+
set noautowrite
10+
endfunc
11+
12+
function TearDown()
13+
let &hidden = s:save_hidden
14+
let &bufhidden = s:save_bufhidden
15+
let &autowrite = s:save_autowrite
16+
endfunc
17+
18+
function Test_hide()
19+
let orig_bname = bufname('')
20+
let orig_winnr = winnr('$')
21+
22+
new Xf1
23+
set modified
24+
call assert_fails('edit Xf2')
25+
bwipeout! Xf1
26+
27+
new Xf1
28+
set modified
29+
edit! Xf2
30+
call assert_equal(['Xf2', 2], [bufname(''), winnr('$')])
31+
call assert_equal([1, 0], [buflisted('Xf1'), bufloaded('Xf1')])
32+
bwipeout! Xf1
33+
bwipeout! Xf2
34+
35+
new Xf1
36+
set modified
37+
" :hide as a command
38+
hide
39+
call assert_equal([orig_bname, orig_winnr], [bufname(''), winnr('$')])
40+
call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
41+
bwipeout! Xf1
42+
43+
new Xf1
44+
set modified
45+
" :hide as a command with trailing comment
46+
hide " comment
47+
call assert_equal([orig_bname, orig_winnr], [bufname(''), winnr('$')])
48+
call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
49+
bwipeout! Xf1
50+
51+
new Xf1
52+
set modified
53+
" :hide as a command with bar
54+
hide | new Xf2 " comment
55+
call assert_equal(['Xf2', 2], [bufname(''), winnr('$')])
56+
call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
57+
bwipeout! Xf1
58+
bwipeout! Xf2
59+
60+
new Xf1
61+
set modified
62+
" :hide as a modifier with trailing comment
63+
hide edit Xf2 " comment
64+
call assert_equal(['Xf2', 2], [bufname(''), winnr('$')])
65+
call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
66+
bwipeout! Xf1
67+
bwipeout! Xf2
68+
69+
new Xf1
70+
set modified
71+
" To check that the bar is not recognized to separate commands
72+
hide echo "one|two"
73+
call assert_equal(['Xf1', 2], [bufname(''), winnr('$')])
74+
call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
75+
bwipeout! Xf1
76+
77+
" set hidden
78+
new Xf1
79+
set hidden
80+
set modified
81+
edit Xf2 " comment
82+
call assert_equal(['Xf2', 2], [bufname(''), winnr('$')])
83+
call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
84+
bwipeout! Xf1
85+
bwipeout! Xf2
86+
87+
" set hidden bufhidden=wipe
88+
new Xf1
89+
set bufhidden=wipe
90+
set modified
91+
hide edit! Xf2 " comment
92+
call assert_equal(['Xf2', 2], [bufname(''), winnr('$')])
93+
call assert_equal([0, 0], [buflisted('Xf1'), bufloaded('Xf1')])
94+
bwipeout! Xf2
95+
endfunc
96+
97+
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,8 @@ static char *(features[]) =
779779

780780
static int included_patches[] =
781781
{ /* Add new patch number below this line */
782+
/**/
783+
86,
782784
/**/
783785
85,
784786
/**/

0 commit comments

Comments
 (0)