Skip to content

Commit

Permalink
Merge pull request #2 from zenangst/develop
Browse files Browse the repository at this point in the history
Disable editing for files inside Pods directory
  • Loading branch information
brianmichel committed Oct 30, 2014
2 parents 8f3e36f + ab58009 commit 3ad7518
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Helmet/NSViewController+Helmet.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ - (void)updateEditibility {
@try {
id editorDocument = [self valueForKey:@"_document"];
id editorTextView = self.hl_EditingTextView;

if ([editorDocument isKindOfClass:NSClassFromString(@"IDESourceCodeDocument")] && [editorTextView isKindOfClass:[NSTextView class]]) {
NSTextView *castTextView = (NSTextView *)editorTextView;
NSURL *fileURL = [editorDocument valueForKeyPath:@"filePath.fileURL"];
BOOL editable = [self filePathIsEditable:fileURL];
castTextView.editable = editable;
}

}
@catch (NSException *exception) {
NSLog(@"[HL] %@", exception);
Expand All @@ -52,9 +52,15 @@ - (void)updateEditibility {

- (BOOL)filePathIsEditable:(NSURL *)filePath {
NSString *absolutePath = [filePath relativePath];

if ([absolutePath hasPrefix:@"/Applications/Xcode.app/"]) {
return NO;
}

if ([absolutePath rangeOfString:@"/Pods/"].location != NSNotFound) {
return NO;
}

return YES;
}

Expand Down

0 comments on commit 3ad7518

Please sign in to comment.