Last active
November 15, 2016 10:57
-
-
Save h-east/c5bad05b9615d521b0245f5d5e8e7420 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Makefile b/src/Makefile | |
index fef53af..eb67126 100644 | |
--- a/src/Makefile | |
+++ b/src/Makefile | |
@@ -2097,6 +2097,7 @@ test_arglist \ | |
test_gui \ | |
test_hardcopy \ | |
test_help_tagjump \ | |
+ test_hide \ | |
test_history \ | |
test_hlsearch \ | |
test_increment \ | |
diff --git a/src/ex_cmds.h b/src/ex_cmds.h | |
index 01126ba..d8fc506 100644 | |
--- a/src/ex_cmds.h | |
+++ b/src/ex_cmds.h | |
@@ -623,7 +623,7 @@ EX(CMD_highlight, "highlight", ex_highlight, | |
BANG|EXTRA|TRLBAR|SBOXOK|CMDWIN, | |
ADDR_LINES), | |
EX(CMD_hide, "hide", ex_hide, | |
- BANG|RANGE|NOTADR|COUNT|EXTRA|NOTRLCOM, | |
+ BANG|RANGE|NOTADR|COUNT|EXTRA|TRLBAR, | |
ADDR_WINDOWS), | |
EX(CMD_history, "history", ex_history, | |
EXTRA|TRLBAR|CMDWIN, | |
diff --git a/src/ex_docmd.c b/src/ex_docmd.c | |
index 6b4e5fb..9fc4001 100644 | |
--- a/src/ex_docmd.c | |
+++ b/src/ex_docmd.c | |
@@ -7572,38 +7572,32 @@ ex_all(exarg_T *eap) | |
static void | |
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 */ | |
- eap->nextcmd = check_nextcmd(eap->arg); | |
+ /* ":hide" or ":hide | cmd": hide current window */ | |
#ifdef FEAT_WINDOWS | |
- if (!eap->skip) | |
- { | |
+ if (!eap->skip) | |
+ { | |
# ifdef FEAT_GUI | |
- need_mouse_correct = TRUE; | |
+ need_mouse_correct = TRUE; | |
# endif | |
- if (eap->addr_count == 0) | |
- win_close(curwin, FALSE); /* don't free buffer */ | |
- else | |
- { | |
- int winnr = 0; | |
- win_T *win; | |
+ if (eap->addr_count == 0) | |
+ win_close(curwin, FALSE); /* don't free buffer */ | |
+ else | |
+ { | |
+ int winnr = 0; | |
+ win_T *win; | |
- FOR_ALL_WINDOWS(win) | |
- { | |
- winnr++; | |
- if (winnr == eap->line2) | |
- break; | |
- } | |
- if (win == NULL) | |
- win = lastwin; | |
- win_close(win, FALSE); | |
+ FOR_ALL_WINDOWS(win) | |
+ { | |
+ winnr++; | |
+ if (winnr == eap->line2) | |
+ break; | |
} | |
+ if (win == NULL) | |
+ win = lastwin; | |
+ win_close(win, FALSE); | |
} | |
-#endif | |
} | |
+#endif | |
} | |
/* | |
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak | |
index a8ea543..1c0c715 100644 | |
--- a/src/testdir/Make_all.mak | |
+++ b/src/testdir/Make_all.mak | |
@@ -156,6 +156,7 @@ NEW_TESTS = test_arglist.res \ | |
test_gn.res \ | |
test_gui.res \ | |
test_hardcopy.res \ | |
+ test_hide.res \ | |
test_history.res \ | |
test_hlsearch.res \ | |
test_increment.res \ | |
diff --git a/src/testdir/test_hide.vim b/src/testdir/test_hide.vim | |
new file mode 100644 | |
index 0000000..128b8ff | |
--- /dev/null | |
+++ b/src/testdir/test_hide.vim | |
@@ -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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment