aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds2.c
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2016-05-10 22:50:31 -0400
committerJames McCoy <jamessan@jamessan.com>2016-05-14 17:16:18 -0400
commit8c399d6b37f967d0ec9991d873666036de196a0a (patch)
tree25c816240e4bee86b6ee96ee0585c601ef9dcc4c /src/nvim/ex_cmds2.c
parent529e2ab17828943cf5004534429eab7a0b08cf91 (diff)
downloadrneovim-8c399d6b37f967d0ec9991d873666036de196a0a.tar.gz
rneovim-8c399d6b37f967d0ec9991d873666036de196a0a.tar.bz2
rneovim-8c399d6b37f967d0ec9991d873666036de196a0a.zip
vim-patch:7.4.1037
Problem: Using "q!" when there is a modified hidden buffer does not unload the current buffer, resulting in the need to abandon it again. Solution: When using "q!" unload the current buffer when needed. (Yasuhiro Matsumoto, Hirohito Higashi) https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Diffstat (limited to 'src/nvim/ex_cmds2.c')
-rw-r--r--src/nvim/ex_cmds2.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 12efddc205..b1dad21b02 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;
@@ -1346,9 +1348,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);