mirror of
https://github.com/vim/vim.git
synced 2025-10-06 05:44:14 -04:00
patch 8.0.0086
Problem: Cannot add a comment after ":hide". (Norio Takagi) Solution: Make it work, add a test. (Hirohito Higashi)
This commit is contained in:
@@ -2097,6 +2097,7 @@ test_arglist \
|
|||||||
test_gui \
|
test_gui \
|
||||||
test_hardcopy \
|
test_hardcopy \
|
||||||
test_help_tagjump \
|
test_help_tagjump \
|
||||||
|
test_hide \
|
||||||
test_history \
|
test_history \
|
||||||
test_hlsearch \
|
test_hlsearch \
|
||||||
test_increment \
|
test_increment \
|
||||||
|
@@ -623,7 +623,7 @@ EX(CMD_highlight, "highlight", ex_highlight,
|
|||||||
BANG|EXTRA|TRLBAR|SBOXOK|CMDWIN,
|
BANG|EXTRA|TRLBAR|SBOXOK|CMDWIN,
|
||||||
ADDR_LINES),
|
ADDR_LINES),
|
||||||
EX(CMD_hide, "hide", ex_hide,
|
EX(CMD_hide, "hide", ex_hide,
|
||||||
BANG|RANGE|NOTADR|COUNT|EXTRA|NOTRLCOM,
|
BANG|RANGE|NOTADR|COUNT|EXTRA|TRLBAR,
|
||||||
ADDR_WINDOWS),
|
ADDR_WINDOWS),
|
||||||
EX(CMD_history, "history", ex_history,
|
EX(CMD_history, "history", ex_history,
|
||||||
EXTRA|TRLBAR|CMDWIN,
|
EXTRA|TRLBAR|CMDWIN,
|
||||||
|
@@ -5632,15 +5632,16 @@ find_nextcmd(char_u *p)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if *p is a separator between Ex commands.
|
* Check if *p is a separator between Ex commands, skipping over white space.
|
||||||
* Return NULL if it isn't, (p + 1) if it is.
|
* Return NULL if it isn't, the following character if it is.
|
||||||
*/
|
*/
|
||||||
char_u *
|
char_u *
|
||||||
check_nextcmd(char_u *p)
|
check_nextcmd(char_u *p)
|
||||||
{
|
{
|
||||||
p = skipwhite(p);
|
char_u *s = skipwhite(p);
|
||||||
if (*p == '|' || *p == '\n')
|
|
||||||
return (p + 1);
|
if (*s == '|' || *s == '\n')
|
||||||
|
return (s + 1);
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -7572,12 +7573,7 @@ ex_all(exarg_T *eap)
|
|||||||
static void
|
static void
|
||||||
ex_hide(exarg_T *eap)
|
ex_hide(exarg_T *eap)
|
||||||
{
|
{
|
||||||
if (*eap->arg != NUL && check_nextcmd(eap->arg) == NULL)
|
|
||||||
eap->errmsg = e_invarg;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* ":hide" or ":hide | cmd": hide current window */
|
/* ":hide" or ":hide | cmd": hide current window */
|
||||||
eap->nextcmd = check_nextcmd(eap->arg);
|
|
||||||
#ifdef FEAT_WINDOWS
|
#ifdef FEAT_WINDOWS
|
||||||
if (!eap->skip)
|
if (!eap->skip)
|
||||||
{
|
{
|
||||||
@@ -7603,7 +7599,6 @@ ex_hide(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -156,6 +156,7 @@ NEW_TESTS = test_arglist.res \
|
|||||||
test_gn.res \
|
test_gn.res \
|
||||||
test_gui.res \
|
test_gui.res \
|
||||||
test_hardcopy.res \
|
test_hardcopy.res \
|
||||||
|
test_hide.res \
|
||||||
test_history.res \
|
test_history.res \
|
||||||
test_hlsearch.res \
|
test_hlsearch.res \
|
||||||
test_increment.res \
|
test_increment.res \
|
||||||
|
97
src/testdir/test_hide.vim
Normal file
97
src/testdir/test_hide.vim
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
" Tests for :hide command/modifier and 'hidden' option
|
||||||
|
|
||||||
|
function SetUp()
|
||||||
|
let s:save_hidden = &hidden
|
||||||
|
let s:save_bufhidden = &bufhidden
|
||||||
|
let s:save_autowrite = &autowrite
|
||||||
|
set nohidden
|
||||||
|
set bufhidden=
|
||||||
|
set noautowrite
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
function TearDown()
|
||||||
|
let &hidden = s:save_hidden
|
||||||
|
let &bufhidden = s:save_bufhidden
|
||||||
|
let &autowrite = s:save_autowrite
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
function Test_hide()
|
||||||
|
let orig_bname = bufname('')
|
||||||
|
let orig_winnr = winnr('$')
|
||||||
|
|
||||||
|
new Xf1
|
||||||
|
set modified
|
||||||
|
call assert_fails('edit Xf2')
|
||||||
|
bwipeout! Xf1
|
||||||
|
|
||||||
|
new Xf1
|
||||||
|
set modified
|
||||||
|
edit! Xf2
|
||||||
|
call assert_equal(['Xf2', 2], [bufname(''), winnr('$')])
|
||||||
|
call assert_equal([1, 0], [buflisted('Xf1'), bufloaded('Xf1')])
|
||||||
|
bwipeout! Xf1
|
||||||
|
bwipeout! Xf2
|
||||||
|
|
||||||
|
new Xf1
|
||||||
|
set modified
|
||||||
|
" :hide as a command
|
||||||
|
hide
|
||||||
|
call assert_equal([orig_bname, orig_winnr], [bufname(''), winnr('$')])
|
||||||
|
call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
|
||||||
|
bwipeout! Xf1
|
||||||
|
|
||||||
|
new Xf1
|
||||||
|
set modified
|
||||||
|
" :hide as a command with trailing comment
|
||||||
|
hide " comment
|
||||||
|
call assert_equal([orig_bname, orig_winnr], [bufname(''), winnr('$')])
|
||||||
|
call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
|
||||||
|
bwipeout! Xf1
|
||||||
|
|
||||||
|
new Xf1
|
||||||
|
set modified
|
||||||
|
" :hide as a command with bar
|
||||||
|
hide | new Xf2 " comment
|
||||||
|
call assert_equal(['Xf2', 2], [bufname(''), winnr('$')])
|
||||||
|
call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
|
||||||
|
bwipeout! Xf1
|
||||||
|
bwipeout! Xf2
|
||||||
|
|
||||||
|
new Xf1
|
||||||
|
set modified
|
||||||
|
" :hide as a modifier with trailing comment
|
||||||
|
hide edit Xf2 " comment
|
||||||
|
call assert_equal(['Xf2', 2], [bufname(''), winnr('$')])
|
||||||
|
call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
|
||||||
|
bwipeout! Xf1
|
||||||
|
bwipeout! Xf2
|
||||||
|
|
||||||
|
new Xf1
|
||||||
|
set modified
|
||||||
|
" To check that the bar is not recognized to separate commands
|
||||||
|
hide echo "one|two"
|
||||||
|
call assert_equal(['Xf1', 2], [bufname(''), winnr('$')])
|
||||||
|
call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
|
||||||
|
bwipeout! Xf1
|
||||||
|
|
||||||
|
" set hidden
|
||||||
|
new Xf1
|
||||||
|
set hidden
|
||||||
|
set modified
|
||||||
|
edit Xf2 " comment
|
||||||
|
call assert_equal(['Xf2', 2], [bufname(''), winnr('$')])
|
||||||
|
call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
|
||||||
|
bwipeout! Xf1
|
||||||
|
bwipeout! Xf2
|
||||||
|
|
||||||
|
" set hidden bufhidden=wipe
|
||||||
|
new Xf1
|
||||||
|
set bufhidden=wipe
|
||||||
|
set modified
|
||||||
|
hide edit! Xf2 " comment
|
||||||
|
call assert_equal(['Xf2', 2], [bufname(''), winnr('$')])
|
||||||
|
call assert_equal([0, 0], [buflisted('Xf1'), bufloaded('Xf1')])
|
||||||
|
bwipeout! Xf2
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" vim: shiftwidth=2 sts=2 expandtab
|
@@ -764,6 +764,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
86,
|
||||||
/**/
|
/**/
|
||||||
85,
|
85,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user