mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Do not open files in "unused windows"
A window is "unused" if it has just been opened with Cmd+n. Previously a file opened from Finder would be opened in an unused window if one was available. This leads to problems with some Vim options, e.g. trying to open an encrypted file from Spotlight will fail. The code that has been removed also had some quite ugly hacks and it is not entirely clear whether the reuse of unused windows was entirely intuitive. (The "Open files from applications" option is not affected by this change.)
This commit is contained in:
@@ -117,7 +117,6 @@ typedef struct
|
||||
#endif
|
||||
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event
|
||||
replyEvent:(NSAppleEventDescriptor *)reply;
|
||||
- (MMVimController *)findUnusedEditor;
|
||||
- (NSMutableDictionary *)extractArgumentsFromOdocEvent:
|
||||
(NSAppleEventDescriptor *)desc;
|
||||
- (void)scheduleVimControllerPreloadAfterDelay:(NSTimeInterval)delay;
|
||||
@@ -1716,18 +1715,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
|
||||
}
|
||||
}
|
||||
|
||||
- (MMVimController *)findUnusedEditor
|
||||
{
|
||||
NSEnumerator *e = [vimControllers objectEnumerator];
|
||||
id vc;
|
||||
while ((vc = [e nextObject])) {
|
||||
if ([[vc objectForVimStateKey:@"unusedEditor"] boolValue])
|
||||
return vc;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)extractArgumentsFromOdocEvent:
|
||||
(NSAppleEventDescriptor *)desc
|
||||
{
|
||||
@@ -2009,15 +1996,8 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
|
||||
|
||||
- (BOOL)openVimControllerWithArguments:(NSDictionary *)arguments
|
||||
{
|
||||
MMVimController *vc = [self findUnusedEditor];
|
||||
MMVimController *vc = [self takeVimControllerFromCache];
|
||||
if (vc) {
|
||||
// Open files in an already open window.
|
||||
// TODO: If the file is encrypted (with -x) then opening in an unused
|
||||
// window will fail if there are more arguments than just the filename
|
||||
// (the same goes with cached Vim controllers).
|
||||
[[[vc windowController] window] makeKeyAndOrderFront:self];
|
||||
[vc passArguments:arguments];
|
||||
} else if ((vc = [self takeVimControllerFromCache])) {
|
||||
// Open files in a new window using a cached vim controller. This
|
||||
// requires virtually no loading time so the new window will pop up
|
||||
// instantaneously.
|
||||
|
||||
@@ -1713,7 +1713,6 @@ static void netbeansReadCallback(CFSocketRef s,
|
||||
NSDictionary *vimState = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[[NSFileManager defaultManager] currentDirectoryPath], @"pwd",
|
||||
[NSNumber numberWithInt:p_mh], @"p_mh",
|
||||
[NSNumber numberWithBool:[self unusedEditor]], @"unusedEditor",
|
||||
[NSNumber numberWithBool:mmta], @"p_mmta",
|
||||
[NSNumber numberWithInt:numTabs], @"numTabs",
|
||||
nil];
|
||||
|
||||
@@ -324,17 +324,6 @@ static BOOL isUnsafeMessage(int msgid);
|
||||
ASLogDebug(@"args=%@", args);
|
||||
|
||||
[self sendMessage:OpenWithArgumentsMsgID data:[args dictionaryAsData]];
|
||||
|
||||
// HACK! Fool findUnusedEditor into thinking that this controller is not
|
||||
// unused anymore, in case it is called before the arguments have reached
|
||||
// the Vim process. This should be a "safe" hack since the next time the
|
||||
// Vim process flushes its output queue the state will be updated again (at
|
||||
// which time the "unusedEditor" state will have been properly set).
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:
|
||||
vimState];
|
||||
[dict setObject:[NSNumber numberWithBool:NO] forKey:@"unusedEditor"];
|
||||
[vimState release];
|
||||
vimState = [dict copy];
|
||||
}
|
||||
|
||||
- (void)sendMessage:(int)msgid data:(NSData *)data
|
||||
|
||||
Reference in New Issue
Block a user