From d3f4f417201a06fecfa2fec4d4e7f939bc45ba43 Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Sat, 17 Jan 2009 20:25:48 +0100 Subject: [PATCH] Respect layout pref when raising an open file For example, with layout set to "arglist" and with 'hidden' enabled, double-clicking an already open (but hidden) file will no longer cause it to open in a new tab. Instead it opens as if the ":buf" command had been used. --- src/MacVim/MMAppController.m | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index f833e3de..709ae786 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -830,6 +830,17 @@ fsEventCallback(ConstFSEventStreamRef streamRef, firstController = vc; } + // The meaning of "layout" is defined by the WIN_* defines in main.c. + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + int layout = [ud integerForKey:MMOpenLayoutKey]; + BOOL splitVert = [ud boolForKey:MMVerticalSplitKey]; + BOOL openInCurrentWindow = [ud boolForKey:MMOpenInCurrentWindowKey]; + + if (splitVert && MMLayoutHorizontalSplit == layout) + layout = MMLayoutVerticalSplit; + if (layout < 0 || (layout > MMLayoutTabs && openInCurrentWindow)) + layout = MMLayoutTabs; + if ([filenames count] == 0) { // Raise the window containing the first file that was already open, // and make sure that the tab containing that file is selected. Only @@ -837,10 +848,18 @@ fsEventCallback(ConstFSEventStreamRef streamRef, // the window with 'firstFile' will be raised, other times it might be // the window that will open with the files in the 'filenames' array. firstFile = [firstFile stringByEscapingSpecialFilenameCharacters]; + + NSString *bufCmd = @"tab sb"; + switch (layout) { + case MMLayoutHorizontalSplit: bufCmd = @"sb"; break; + case MMLayoutVerticalSplit: bufCmd = @"vert sb"; break; + case MMLayoutArglist: bufCmd = @"b"; break; + } + NSString *input = [NSString stringWithFormat:@"" ":let oldswb=&swb|let &swb=\"useopen,usetab\"|" - "tab sb %@|let &swb=oldswb|unl oldswb|" - "cal foreground()", firstFile]; + "%@ %@|let &swb=oldswb|unl oldswb|" + "cal foreground()", bufCmd, firstFile]; [firstController addVimInput:input]; @@ -857,23 +876,13 @@ fsEventCallback(ConstFSEventStreamRef streamRef, // // b) Open any remaining files // - MMVimController *vc; - NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - BOOL openInCurrentWindow = [ud boolForKey:MMOpenInCurrentWindowKey]; - - // The meaning of "layout" is defined by the WIN_* defines in main.c. - int layout = [ud integerForKey:MMOpenLayoutKey]; - BOOL splitVert = [ud boolForKey:MMVerticalSplitKey]; - if (splitVert && MMLayoutHorizontalSplit == layout) - layout = MMLayoutVerticalSplit; - if (layout < 0 || (layout > MMLayoutTabs && openInCurrentWindow)) - layout = MMLayoutTabs; [arguments setObject:[NSNumber numberWithInt:layout] forKey:@"layout"]; [arguments setObject:filenames forKey:@"filenames"]; // (Indicate that files should be opened from now on.) [arguments setObject:[NSNumber numberWithBool:NO] forKey:@"dontOpen"]; + MMVimController *vc; if (openInCurrentWindow && (vc = [self topmostVimController])) { // Open files in an already open window. [[[vc windowController] window] makeKeyAndOrderFront:self]; -- 2.11.4.GIT