From e126fa9652c19cf89ef7262dc639abe99d88294e Mon Sep 17 00:00:00 2001 From: Yee Cheng Chin Date: Sat, 24 Nov 2018 04:11:08 -0800 Subject: [PATCH 1/2] Fix tab dragging crashing under 10.14 due to deprecated API Use the newer `cacheDisplayInRect:toBitmapImageRep:` API instead to work around this. --- src/MacVim/PSMTabBarControl/source/PSMTabBarCell.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/MacVim/PSMTabBarControl/source/PSMTabBarCell.m b/src/MacVim/PSMTabBarControl/source/PSMTabBarCell.m index 65b3b25052..6f1a06e462 100644 --- a/src/MacVim/PSMTabBarControl/source/PSMTabBarCell.m +++ b/src/MacVim/PSMTabBarControl/source/PSMTabBarCell.m @@ -338,7 +338,10 @@ - (NSImage*)dragImageForRect:(NSRect)cellFrame if(([self state] == NSOnState) && ([[_controlView styleName] isEqualToString:@"Metal"])) cellFrame.size.width += 1.0; [_controlView lockFocus]; - NSBitmapImageRep *rep = [[[NSBitmapImageRep alloc] initWithFocusedViewRect:cellFrame] autorelease]; + + NSBitmapImageRep *rep = [[self controlView] bitmapImageRepForCachingDisplayInRect:cellFrame]; + [[self controlView] cacheDisplayInRect:cellFrame toBitmapImageRep:rep]; + [_controlView unlockFocus]; NSImage *image = [[[NSImage alloc] initWithSize:[rep size]] autorelease]; [image addRepresentation:rep]; From 7e1b43e6c2f40c192b65692672492655fb023ca5 Mon Sep 17 00:00:00 2001 From: Yee Cheng Chin Date: Sat, 24 Nov 2018 04:12:03 -0800 Subject: [PATCH 2/2] Fix tab dragging not working when dragging a tab to the right Vim's tabmove has two positions where it doesn't do anything, so need to add 1 to index when moving tab to the right. Fix #257 --- src/MacVim/MMBackend.m | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index 1933f75555..855992408f 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -2013,6 +2013,14 @@ - (void)handleInputEvent:(int)msgid data:(NSData *)data // based. int idx = *((int*)bytes); + // Also, this index doesn't take itself into account, so if the move is + // to a later tab, need to add one to it since Vim's tabpage_move *does* + // count the current tab. + int curtab_index = tabpage_index(curtab); + if (idx >= curtab_index) { + idx += 1; + } + tabpage_move(idx); } else if (SetTextDimensionsMsgID == msgid || LiveResizeMsgID == msgid || SetTextDimensionsNoResizeWindowMsgID == msgid