aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds2.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2016-05-15 22:50:17 -0400
committerJustin M. Keyes <justinkz@gmail.com>2016-05-15 22:50:17 -0400
commit71450b54aa22fd1d60e5b4d0929f254a56c8869d (patch)
treea12909d6ec1a9b5cd91ff79b8d43275ab16814de /src/nvim/ex_cmds2.c
parent082abb7ca6f45fa937a0377a5edc68929a1c08a9 (diff)
parent92fe357a523de1a4bed0c5778389dc7d669d29c4 (diff)
downloadrneovim-71450b54aa22fd1d60e5b4d0929f254a56c8869d.tar.gz
rneovim-71450b54aa22fd1d60e5b4d0929f254a56c8869d.tar.bz2
rneovim-71450b54aa22fd1d60e5b4d0929f254a56c8869d.zip
Merge pull request #4743 from jamessan/vim-7.4.1037
vim-patch:7.4.1037,fa73534
Diffstat (limited to 'src/nvim/ex_cmds2.c')
-rw-r--r--src/nvim/ex_cmds2.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 12efddc205..df387f9a60 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -1241,16 +1241,18 @@ static void add_bufnum(int *bufnrs, int *bufnump, int nr)
*bufnump = *bufnump + 1;
}
-/*
- * Return TRUE if any buffer was changed and cannot be abandoned.
- * That changed buffer becomes the current buffer.
- */
-int
-check_changed_any (
- int hidden /* Only check hidden buffers */
-)
-{
- int ret = FALSE;
+/// Check if any buffer was changed and cannot be abandoned.
+/// That changed buffer becomes the current buffer.
+/// When "unload" is true the current buffer is unloaded instead of making it
+/// hidden. This is used for ":q!".
+///
+/// @param[in] hidden specifies whether to check only hidden buffers.
+/// @param[in] unload specifies whether to unload, instead of hide, the buffer.
+///
+/// @returns true if any buffer is changed and cannot be abandoned
+int check_changed_any(bool hidden, bool unload)
+{
+ bool ret = false;
int save;
int i;
int bufnum = 0;
@@ -1261,8 +1263,9 @@ check_changed_any (
++bufcount;
}
- if (bufcount == 0)
- return FALSE;
+ if (bufcount == 0) {
+ return false;
+ }
bufnrs = xmalloc(sizeof(*bufnrs) * bufcount);
@@ -1346,9 +1349,10 @@ check_changed_any (
}
buf_found:
- /* Open the changed buffer in the current window. */
- if (buf != curbuf)
- set_curbuf(buf, DOBUF_GOTO);
+ // Open the changed buffer in the current window.
+ if (buf != curbuf) {
+ set_curbuf(buf, unload ? DOBUF_UNLOAD : DOBUF_GOTO);
+ }
theend:
xfree(bufnrs);