mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-07 15:37:14 +02:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user