diff src/gui.c @ 14428:aab5947be7c5 v8.1.0228

patch 8.1.0228: dropping files is ignored while Vim is busy commit https://github.com/vim/vim/commit/92d147be959e689f8f58fd5d138a31835e160289 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 29 17:35:23 2018 +0200 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.
author Christian Brabandt <cb@256bit.org>
date Sun, 29 Jul 2018 17:45:05 +0200
parents 0a69e6e708f9
children 27b9a84395b5
line wrap: on
line diff
--- a/src/gui.c
+++ b/src/gui.c
@@ -5383,10 +5383,7 @@ gui_do_findrepl(
 
 #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 @@ gui_wingoto_xy(int x, int y)
 }
 
 /*
+ * 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 @@ gui_handle_drop(
 	    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;