Don't attempt to open dropped file that is already open

When a file is dropped, each Vim process is checked to see if the file is
already open.  If so, raise the corresponding window and select the tab that
holds the opened file.  Only works when one file is dropped.
This commit is contained in:
Bjorn Winckler
2007-11-08 20:14:34 +01:00
parent 702917f6ed
commit 94e4efed2d
+8 -3
View File
@@ -181,15 +181,20 @@ static NSTimeInterval MMReplyTimeout = 5;
for (i = 0; i < count; ++i) {
MMVimController *controller = [vimControllers objectAtIndex:i];
id proxy = [controller backendProxy];
NSString *file = [[files objectAtIndex:0]
stringByEscapingSpecialFilenameCharacters];
@try {
NSString *expr = [NSString stringWithFormat:
@"bufloaded(\"%@\")", [files objectAtIndex:0]];
@"bufloaded(\"%@\")", file];
NSString *eval = [proxy evaluateExpression:expr];
if ([eval isEqual:@"1"]) {
// TODO: Select the tab with 'file' open.
[controller addVimInput:
@"<C-\\><C-N>:cal foreground()<CR>"];
NSString *input = [NSString stringWithFormat:@"<C-\\><C-N>"
":let oldswb=&swb|let &swb=\"useopen,usetab\"|"
"tab sb %@|let &swb=oldswb|unl oldswb|"
"cal foreground()|redr|f<CR>", file];
[controller addVimInput:input];
return;
}
}