Skip to content

Commit 3e6c983

Browse files
committed
Launcher: fixed completion history items selecting.
1 parent 9b7f93a commit 3e6c983

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

Applications/Workspace/Launcher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
id window;
2727
id commandField;
2828
id runInTerminal;
29-
id completionList;
29+
IBOutlet NSBrowser *completionList;
3030
id runButton;
3131

3232
NSArray *searchPaths;

Applications/Workspace/Launcher.m

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,12 @@ - (void)activate
9797
if (window == nil) {
9898
[NSBundle loadNibNamed:@"Launcher" owner:self];
9999
} else {
100+
NSString *fieldValue = [commandField stringValue];
100101
[completionList reloadColumn:0];
101-
// [completionList setTitle:@"History" ofColumn:0];
102+
[completionList setTitle:@"History" ofColumn:0];
103+
if (fieldValue.length > 0) {
104+
[completionList selectRow:[historyList indexOfObject:fieldValue] inColumn:0];
105+
}
102106
}
103107

104108
[commandField selectText:nil];
@@ -158,9 +162,13 @@ - (void)runCommand:(id)sender
158162
} @catch (NSException *exception) {
159163
NXTRunAlertPanel(@"Run Command", @"Run command failed with exception: \'%@\'", @"Close", nil,
160164
nil, [exception reason]);
161-
} @finally {
162-
[window close];
165+
[window makeKeyAndOrderFront:self];
166+
return;
163167
}
168+
// @finally {
169+
// [window close];
170+
// }
171+
[window close];
164172
}
165173

166174
- (void)runInTerminal:(id)sender
@@ -445,6 +453,7 @@ - (void)listItemClicked:(id)sender
445453
{
446454
NSInteger selRow;
447455
NSString *absPath;
456+
NSString *fieldValue = [commandField stringValue];
448457
id object;
449458

450459
if (sender != completionList)
@@ -455,7 +464,7 @@ - (void)listItemClicked:(id)sender
455464
if (absPath == nil) {
456465
absPath = [completionSource objectAtIndex:completionIndex];
457466
}
458-
if ([[commandField stringValue] characterAtIndex:0] == '~') {
467+
if (fieldValue && fieldValue.length > 0 && [fieldValue characterAtIndex:0] == '~') {
459468
absPath = [absPath stringByAbbreviatingWithTildeInPath];
460469
}
461470

0 commit comments

Comments
 (0)