Permalink
Browse files

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.
  • Loading branch information...
1 parent cc43c3f commit c96d4dcc8e5b65bf989efa7e1b86f262974f935c @b4winckler committed Oct 3, 2010
Showing with 14 additions and 14 deletions.
  1. +14 −14 src/MacVim/MMBackend.m
@@ -193,7 +193,6 @@ - (void)handleXcodeMod:(NSData *)data;
- (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 @@ - (void)handleOpenWithArguments:(NSDictionary *)args
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 @@ - (void)handleOpenWithArguments:(NSDictionary *)args
// 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

0 comments on commit c96d4dc

Please sign in to comment.