Anonymous avatar Anonymous committed f3d4640

Preferences: filter out apps that can't be found in the file system

Comments (0)

Files changed (1)

Source/MercurialApp.m

     if (!s_supportedTextEditors) {
         NSString *path = [[NSBundle mainBundle] pathForResource: @"TextEditors" ofType: @"plist"];
         s_supportedTextEditors = [NSArray arrayWithContentsOfFile: path];
+
+        // filter apps that can't be found
+        NSMutableArray *tmpSupportedTextEditors = [s_supportedTextEditors mutableCopy];
+        for (NSDictionary *value in s_supportedTextEditors) {
+            if ([[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:(NSString *)[value objectForKey:@"editorID"]] == nil)
+                [tmpSupportedTextEditors removeObject:value];
+        }
+        s_supportedTextEditors = [tmpSupportedTextEditors copy];
+
         Assert(s_supportedTextEditors);
     }
     return s_supportedTextEditors;
     [_textEditorPreferenceButton addItemsWithTitles:[[self supportedTextEditors] valueForKeyPath:@"@unionOfObjects.editorName"]];
 
     for (id item in [[self supportedTextEditors] valueForKeyPath:@"@unionOfObjects.editorID"]) {
-        NSString *path = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:(NSString *)item];
-
-        if (path != nil) { // app was found
-            NSMenuItem *menuItem = [_textEditorPreferenceButton itemAtIndex:[[[self supportedTextEditors] valueForKeyPath:@"@unionOfObjects.editorID"] indexOfObject:item]];
-            [menuItem setImage:[[NSWorkspace sharedWorkspace] iconForFile:path]];
-            [[menuItem image] setSize:NSMakeSize(16, 16)];
-        }
+        NSMenuItem *menuItem = [_textEditorPreferenceButton itemAtIndex:[[[self supportedTextEditors] valueForKeyPath:@"@unionOfObjects.editorID"] indexOfObject:item]];
+        [menuItem setImage:[[NSWorkspace sharedWorkspace] iconForFile:[[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:(NSString *)item]]];
+        [[menuItem image] setSize:NSMakeSize(16, 16)];
     }
 
    NSString *selectedEditorID = [[NSUserDefaults standardUserDefaults] stringForKey:kPrefPreferredTextEditorID];
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.