aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/quickfix.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-10-17 12:24:52 -0400
committerGitHub <noreply@github.com>2020-10-17 12:24:52 -0400
commitc8ce098e7109f6d62ea0de59d610fcb6132ad221 (patch)
treea5fc7392ee76a62d00437e010e036a09342b8e9a /src/nvim/quickfix.c
parent288f7f8558c331fadcc72e9c7391fff08d42ba36 (diff)
parentb9fe30cac2967a4f7bc29d32a3cf1196fa3a1f3a (diff)
downloadrneovim-c8ce098e7109f6d62ea0de59d610fcb6132ad221.tar.gz
rneovim-c8ce098e7109f6d62ea0de59d610fcb6132ad221.tar.bz2
rneovim-c8ce098e7109f6d62ea0de59d610fcb6132ad221.zip
Merge pull request #13105 from janlazo/vim-8.2.0728
vim-patch:8.2.{444,778,1219,1384,1557}
Diffstat (limited to 'src/nvim/quickfix.c')
-rw-r--r--src/nvim/quickfix.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 5ade59d224..4d3d0f5fdf 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -5068,6 +5068,20 @@ static void vgr_jump_to_match(qf_info_T *qi, int forceit, int *redraw_for_dummy,
}
}
+// Return true if "buf" had an existing swap file, the current swap file does
+// not end in ".swp".
+static bool existing_swapfile(const buf_T *buf)
+ FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
+{
+ if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL) {
+ const char_u *const fname = buf->b_ml.ml_mfp->mf_fname;
+ const size_t len = STRLEN(fname);
+
+ return fname[len - 1] != 'p' || fname[len - 2] != 'w';
+ }
+ return false;
+}
+
// ":vimgrep {pattern} file(s)"
// ":vimgrepadd {pattern} file(s)"
// ":lvimgrep {pattern} file(s)"
@@ -5225,7 +5239,9 @@ void ex_vimgrep(exarg_T *eap)
if (!found_match) {
wipe_dummy_buffer(buf, dirname_start);
buf = NULL;
- } else if (buf != first_match_buf || (flags & VGR_NOJUMP)) {
+ } else if (buf != first_match_buf
+ || (flags & VGR_NOJUMP)
+ || existing_swapfile(buf)) {
unload_dummy_buffer(buf, dirname_start);
// Keeping the buffer, remove the dummy flag.
buf->b_flags &= ~BF_DUMMY;