Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit c96d4dcc8e5b65bf989efa7e1b86f262974f935c 1 parent cc43c3f
@b4winckler authored
Showing with 14 additions and 14 deletions.
  1. +14 −14 src/MacVim/MMBackend.m
View
28 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
Please sign in to comment.
Something went wrong with that request. Please try again.