diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index 00d7f646cf..be710e5f91 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -819,6 +819,10 @@ fsEventCallback(ConstFSEventStreamRef streamRef, NSMutableDictionary *arguments = (args ? [[args mutableCopy] autorelease] : [NSMutableDictionary dictionary]); + // Filenames on HFS+ are in NFD but Vim does not handle this form very well + // so normalize to NFKC first. + filenames = normalizeFilenames(filenames); + // // a) Filter out any already open files // diff --git a/src/MacVim/MMVimController.m b/src/MacVim/MMVimController.m index 1ade6a4aba..f21044c064 100644 --- a/src/MacVim/MMVimController.m +++ b/src/MacVim/MMVimController.m @@ -263,6 +263,10 @@ static BOOL isUnsafeMessage(int msgid); if (splitVert && MMLayoutHorizontalSplit == layout) layout = MMLayoutVerticalSplit; + // Filenames on HFS+ are in NFD but Vim does not handle this form very well + // so normalize to NFKC first. + filenames = normalizeFilenames(filenames); + NSDictionary *args = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:layout], @"layout", filenames, @"filenames", diff --git a/src/MacVim/Miscellaneous.h b/src/MacVim/Miscellaneous.h index 9e8da0152b..0e41fda8d3 100644 --- a/src/MacVim/Miscellaneous.h +++ b/src/MacVim/Miscellaneous.h @@ -135,3 +135,10 @@ enum { // release it. NSView *showHiddenFilesView(); + +// Convert filenames (which are in decomposed form, NFD, on HFS+) to +// normalization form combatibility C (NFKC). (This is necessary because Vim +// does not automatically compose NFD. We choose NFKC instead of NFC for the +// somewhat random reason that this is what is used on Windows and hence +// hopefully Vim is better prepared for it.) +NSArray *normalizeFilenames(NSArray *filenames); diff --git a/src/MacVim/Miscellaneous.m b/src/MacVim/Miscellaneous.m index 44f662298a..bb386c9c25 100644 --- a/src/MacVim/Miscellaneous.m +++ b/src/MacVim/Miscellaneous.m @@ -290,3 +290,23 @@ showHiddenFilesView() return button; } + + + + + NSArray * +normalizeFilenames(NSArray *filenames) +{ + NSMutableArray *outnames = [NSMutableArray array]; + if (!filenames) + return outnames; + + unsigned i, count = [filenames count]; + for (i = 0; i < count; ++i) { + NSString *nfkc = [filenames objectAtIndex:i]; + nfkc = [nfkc precomposedStringWithCompatibilityMapping]; + [outnames addObject:nfkc]; + } + + return outnames; +}