0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

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.
This commit is contained in:
Bram Moolenaar
2018-07-29 17:35:23 +02:00
parent fda95e7572
commit 92d147be95
8 changed files with 202 additions and 115 deletions

View File

@@ -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);
@@ -5408,6 +5405,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
@@ -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;