From c96d4dcc8e5b65bf989efa7e1b86f262974f935c Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Sun, 3 Oct 2010 17:49:23 +0200 Subject: [PATCH] Do not change pwd on open file for onscreen window This change is to make the behavior more consistent and easier to predict (e.g. when MacVim is used with PeepOpen). If opening new files causes a new window to appear on screen, then the pwd is set to the directory of the first file being opened. If a window is already visible and new files are set to open in the "current" window, then the pwd will not change when opening files. --- src/MacVim/MMBackend.m | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index c39c8b1ff2..4562077914 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -193,7 +193,6 @@ extern GuiFont gui_mch_retain_font(GuiFont font); - (void)handleOpenWithArguments:(NSDictionary *)args; - (BOOL)checkForModifiedBuffers; - (void)addInput:(NSString *)input; -- (BOOL)unusedEditor; - (void)redrawScreen; - (void)handleFindReplace:(NSDictionary *)args; - (void)handleMarkedText:(NSData *)data; @@ -2640,19 +2639,6 @@ static void netbeansReadCallback(CFSocketRef s, BOOL openFiles = ![[args objectForKey:@"dontOpen"] boolValue]; int layout = [[args objectForKey:@"layout"] intValue]; - // Change to directory of first file to open if this is an "unused" editor - // (but do not do this if editing remotely). - if (openFiles && numFiles > 0 && ![args objectForKey:@"remoteID"] - && (starting || [self unusedEditor]) ) { - char_u *s = [[filenames objectAtIndex:0] vimStringSave]; - if (mch_isdir(s)) { - mch_chdir((char*)s); - } else { - vim_chdirfile(s); - } - vim_free(s); - } - if (starting > 0) { // When Vim is starting we simply add the files to be opened to the // global arglist and Vim will take care of opening them for us. @@ -2672,6 +2658,20 @@ static void netbeansReadCallback(CFSocketRef s, // in windows or tabs; all we must do is to specify which layout to // use. initialWindowLayout = layout; + + // Change to directory of first file to open. + // NOTE: This is only done when Vim is starting to avoid confusion: + // if a window is already open the pwd is never touched. + if (openFiles && numFiles > 0 && ![args objectForKey:@"remoteID"]) + { + char_u *s = [[filenames objectAtIndex:0] vimStringSave]; + if (mch_isdir(s)) { + mch_chdir((char*)s); + } else { + vim_chdirfile(s); + } + vim_free(s); + } } } else { // When Vim is already open we resort to some trickery to open the