Skip to content

Commit 7ec24fa

Browse files
committed
Fix drag-and-drop with swap file enabled causing MacVim to freeze
MMBackend's `handleOpenWithArguments` previously set a "flushDisabled" flag to disable all flushing during handling the files. This was unsafe, because under the new code that handles editing immediately (instead of building a deferred set of Ex commands) MacVim tries to immediately pop up a dialog box but that message doesn't get properly flushed because it's disabled. Just remove the setting of that disabled flag as it doesn't seem like it's gaining anything. If we want to have a way to disable flushing for performance reasons in the future , we should make sure the "force" flag in flushQueue: actually gets respected and used properly (only when we want to force it). Right now the "force" flag isn't actually used. Also, make sure the dialog handling code handles the "no GUI resize" resize message (which gets set when we have `guioptions+=k`) as well and don't drop the message. Otherwise if drag-and-drop opens a new tab (since there are multiple files dropped) and the user has guioptions+=k, it won't get redrawn properly because the SetTextDimensionsNoResizeWindowMsgID message would get dropped. It's unfortunate it's a hardcoded hack like this and this should be revisited in the future. Fix #913
1 parent 0cbfb73 commit 7ec24fa

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

src/MacVim/MMBackend.m

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -636,10 +636,12 @@ - (void)update
636636

637637
- (void)flushQueue:(BOOL)force
638638
{
639-
// NOTE: This variable allows for better control over when the queue is
640-
// flushed. It can be set to YES at the beginning of a sequence of calls
641-
// that may potentially add items to the queue, and then restored back to
642-
// NO.
639+
// TODO: "force" is currently unused. When flushDisabled is set, it will
640+
// always disable flushing. Consider fixing it so that force will actually
641+
// forcefully flush (i.e. ignore flushDisabled), and change
642+
// gui_macvim_flush() to call flushQueue with
643+
// force set to NO.
644+
643645
if (flushDisabled) return;
644646

645647
if ([drawData length] > 0) {
@@ -1793,7 +1795,7 @@ - (void)waitForDialogReturn
17931795
if (count%2 == 0) {
17941796
for (i = count-2; i >= 0; i -= 2) {
17951797
int msgid = [[inputQueue objectAtIndex:i] intValue];
1796-
if (SetTextDimensionsMsgID == msgid) {
1798+
if (SetTextDimensionsMsgID == msgid || SetTextDimensionsNoResizeWindowMsgID == msgid) {
17971799
textDimData = [[inputQueue objectAtIndex:i+1] retain];
17981800
break;
17991801
}
@@ -2716,10 +2718,6 @@ - (void)handleOpenWithArguments:(NSDictionary *)args
27162718
bufHasFilename = curbuf->b_ffname != NULL;
27172719
}
27182720

2719-
// Temporarily disable flushing since the following code may
2720-
// potentially cause multiple redraws.
2721-
flushDisabled = YES;
2722-
27232721
// Make sure we're in normal mode first.
27242722
// TODO: The mixing of addInput and Ex commands is a little
27252723
// problematic because addInput is asynchronous and will therefore
@@ -2959,8 +2957,6 @@ - (void)handleOpenWithArguments:(NSDictionary *)args
29592957
out_flush();
29602958
gui_update_cursor(FALSE, FALSE);
29612959
maketitle();
2962-
2963-
flushDisabled = NO;
29642960
}
29652961
}
29662962

0 commit comments

Comments
 (0)