diff src/quickfix.c @ 11589:39787def24bb v8.0.0677

patch 8.0.0677: setting 'filetype' may switch buffers commit https://github.com/vim/vim/commit/1814183b865059679f6ee526ec23fc575e536e66 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 25 21:17:25 2017 +0200 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)
author Christian Brabandt <cb@256bit.org>
date Sun, 25 Jun 2017 21:30:04 +0200
parents f5add45f9848
children 6f11697fb92c
line wrap: on
line diff
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -3425,6 +3425,9 @@ qf_fill_buffer(qf_info_T *qi, buf_T *buf
 	/* 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
 	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);