summaryrefslogtreecommitdiff
path: root/src/quickfix.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-06-25 21:17:25 +0200
committerBram Moolenaar <Bram@vim.org>2017-06-25 21:17:25 +0200
commit1814183b865059679f6ee526ec23fc575e536e66 (patch)
tree27687232ab6376a33759072132c4e3bf9c20ba17 /src/quickfix.c
parent182a17b1e80b92826204d967808df0d30eb2ef27 (diff)
downloadvim-1814183b865059679f6ee526ec23fc575e536e66.zip
patch 8.0.0677: setting 'filetype' may switch buffers
Problem: Setting 'filetype' internally may cause the current buffer and window to change unexpectedly. Solution: Set curbuf_lock. (closes #1734)
Diffstat (limited to 'src/quickfix.c')
-rw-r--r--src/quickfix.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/quickfix.c b/src/quickfix.c
index 40b6fe93d..084d82ec0 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -3425,6 +3425,9 @@ qf_fill_buffer(qf_info_T *qi, buf_T *buf, qfline_T *old_last)
/* Set the 'filetype' to "qf" each time after filling the buffer.
* This resembles reading a file into a buffer, it's more logical when
* using autocommands. */
+#ifdef FEAT_AUTOCMD
+ ++curbuf_lock;
+#endif
set_option_value((char_u *)"ft", 0L, (char_u *)"qf", OPT_LOCAL);
curbuf->b_p_ma = FALSE;
@@ -3435,6 +3438,7 @@ qf_fill_buffer(qf_info_T *qi, buf_T *buf, qfline_T *old_last)
apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL,
FALSE, curbuf);
keep_filetype = FALSE;
+ --curbuf_lock;
#endif
/* make sure it will be redrawn */
redraw_curbuf_later(NOT_VALID);