patch 8.1.0228: dropping files is ignored while Vim is busy
Problem: Dropping files is ignored while Vim is busy.
Solution: Postpone the effect of dropping files until it's safe.
diff --git a/src/gui.c b/src/gui.c
index 15adb1f..82ca09d 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -5383,10 +5383,7 @@
#endif
-#if (defined(FEAT_DND) && defined(FEAT_GUI_GTK)) \
- || defined(FEAT_GUI_MSWIN) \
- || defined(FEAT_GUI_MAC) \
- || defined(PROTO)
+#if defined(HAVE_DROP_FILE) || defined(PROTO)
static void gui_wingoto_xy(int x, int y);
@@ -5409,6 +5406,42 @@
}
/*
+ * Function passed to handle_drop() for the actions to be done after the
+ * argument list has been updated.
+ */
+ static void
+drop_callback(void *cookie)
+{
+ char_u *p = cookie;
+
+ /* If Shift held down, change to first file's directory. If the first
+ * item is a directory, change to that directory (and let the explorer
+ * plugin show the contents). */
+ if (p != NULL)
+ {
+ if (mch_isdir(p))
+ {
+ if (mch_chdir((char *)p) == 0)
+ shorten_fnames(TRUE);
+ }
+ else if (vim_chdirfile(p, "drop") == OK)
+ shorten_fnames(TRUE);
+ vim_free(p);
+ }
+
+ /* Update the screen display */
+ update_screen(NOT_VALID);
+# ifdef FEAT_MENU
+ gui_update_menus(0);
+# endif
+#ifdef FEAT_TITLE
+ maketitle();
+#endif
+ setcursor();
+ out_flush_cursor(FALSE, FALSE);
+}
+
+/*
* Process file drop. Mouse cursor position, key modifiers, name of files
* and count of files are given. Argument "fnames[count]" has full pathnames
* of dropped files, they will be freed in this function, and caller can't use
@@ -5488,33 +5521,8 @@
vim_free(fnames);
}
else
- handle_drop(count, fnames, (modifiers & MOUSE_CTRL) != 0);
-
- /* If Shift held down, change to first file's directory. If the first
- * item is a directory, change to that directory (and let the explorer
- * plugin show the contents). */
- if (p != NULL)
- {
- if (mch_isdir(p))
- {
- if (mch_chdir((char *)p) == 0)
- shorten_fnames(TRUE);
- }
- else if (vim_chdirfile(p, "drop") == OK)
- shorten_fnames(TRUE);
- vim_free(p);
- }
-
- /* Update the screen display */
- update_screen(NOT_VALID);
-# ifdef FEAT_MENU
- gui_update_menus(0);
-# endif
-#ifdef FEAT_TITLE
- maketitle();
-#endif
- setcursor();
- out_flush_cursor(FALSE, FALSE);
+ handle_drop(count, fnames, (modifiers & MOUSE_CTRL) != 0,
+ drop_callback, (void *)p);
}
entered = FALSE;