Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix opening files with symbolic links #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AckMate.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "mkdir -p \"$HOME/Library/Application Support/TextMate/PlugIns\"\ncp -pR \"${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}\" \"$HOME/Library/Application Support/TextMate/PlugIns\"";
shellScript = "mkdir -p \"$HOME/Library/Application Support/TextMate/PlugIns\"\n# adapted from: http://developer.apple.com/mac/library/qa/qa2006/qa1500.html\n# Depending on the build configuration, either copy or link to the most recent product\nrm -rf \"$HOME/Library/Application Support/TextMate/PlugIns/${FULL_PRODUCT_NAME}\"\nif [ \"${CONFIGURATION}\" == \"Debug\" ]; then\n # if we're debugging, add a symbolic link to the plug-in\n ln -sf \"${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}\" \\\n \"$HOME/Library/Application Support/TextMate/PlugIns/${FULL_PRODUCT_NAME}\"\nelif [ \"${CONFIGURATION}\" == \"Release\" ]; then\n # if we're compiling for release, just copy the plugin to the Internet Plug-ins folder\n cp -pR \"${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}\" \"$HOME/Library/Application Support/TextMate/PlugIns\"\nfi";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
1 change: 1 addition & 0 deletions source/controllers/JPAckWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extern NSString * const kJPAckWindowPosition;
NSString* selectedSearchFolder;
BOOL selectionSearch;
NSString* fileName;
NSTask* mateTask;

NSMutableDictionary* preferences;
NSArray* history;
Expand Down
30 changes: 12 additions & 18 deletions source/controllers/JPAckWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ - (void)updateSearchSelectionForEvent:(NSEvent*)event;
@property(nonatomic, retain) NSArray* ackTypes;
@property(nonatomic, readwrite, copy) NSArray* history;
@property(nonatomic, copy) NSString* selectedSearchFolder;
@property(retain) NSTask* mateTask;
@end

@implementation JPAckWindowController
Expand Down Expand Up @@ -50,6 +51,7 @@ @implementation JPAckWindowController
@synthesize folders;
@synthesize currentProcess;
@synthesize currentTypesProcess;
@synthesize mateTask;

+ (NSSet*)keyPathsForValuesAffectingRunning
{
Expand Down Expand Up @@ -88,6 +90,8 @@ - (id)initWithProjectDirectory:(NSString*)directory controller:(id)controller pr
preferences = prefs;
pasteboardChangeCount = NSNotFound;

mateTask = nil;

NSString* projectfile = [projectController filename] ? [projectController filename] : directory;
fileName = [[[projectfile lastPathComponent] stringByDeletingPathExtension] copy];
projectDirectory = [directory copy];
Expand Down Expand Up @@ -327,27 +331,17 @@ - (void)loadAckTypes
- (void)openProjectFile:(NSString*)file atLine:(NSString*)line selectionRange:(NSRange)selectionRange
{
NSString* absolute = [projectDirectory stringByAppendingPathComponent:file];
[[[NSApplication sharedApplication] delegate] openFiles:[NSArray arrayWithObject:absolute]];

for (NSWindow *w in [[NSApplication sharedApplication] orderedWindows])
{
id wc = [w windowController];
NSString* openFileName = nil;

if ([[wc className] isEqualToString:@"OakProjectController"] || [[wc className] isEqualToString:@"OakDocumentController"])
openFileName = [[[wc textView] document] filename];
self.mateTask = [[[NSTask alloc] init] autorelease];
[self.mateTask setCurrentDirectoryPath:projectDirectory];
[self.mateTask setLaunchPath:@"/usr/bin/env"];

if ([openFileName isEqualToString:absolute])
{
[[wc textView] goToLineNumber:line];
[[wc textView] goToColumnNumber:[NSNumber numberWithInt:selectionRange.location + 1]];
NSMutableArray* args = [NSMutableArray arrayWithObjects:@"mate", absolute, nil];
[args addObject:@"-l"];
[args addObject:line];

if (selectionRange.length > 0)
[[wc textView] selectToLine:line andColumn:[NSNumber numberWithInt:selectionRange.location + selectionRange.length + 1]];

break;
}
}
[self.mateTask setArguments:args];
[self.mateTask launch];
}

- (IBAction)cancel:(id)sender
Expand Down