@@ -58,18 +58,16 @@ - (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row {
58
58
return YES ;
59
59
}
60
60
if (row >= 0 && row < configuration.profiles .count ) {
61
- return [self validateCurrentProfile ];
61
+ if ([self validateCurrentProfile ]) {
62
+ [self saveCurrentProfile ];
63
+ } else {
64
+ return NO ;
65
+ }
62
66
}
63
67
// always allow selection to no selection
64
68
return YES ;
65
69
}
66
70
67
- - (void )tableViewSelectionIsChanging : (NSNotification *)notification {
68
- if (self.tableView .selectedRow >= 0 ) {
69
- [self saveCurrentProfile ];
70
- }
71
- }
72
-
73
71
- (void )tableViewSelectionDidChange : (NSNotification *)notification {
74
72
if (self.tableView .selectedRow >= 0 ) {
75
73
[self loadCurrentProfile ];
@@ -116,9 +114,14 @@ - (IBAction)remove:(id)sender {
116
114
[((NSMutableArray *) configuration.profiles) removeObjectAtIndex: selection];
117
115
[self .tableView reloadData ];
118
116
[self updateSettingsBoxVisible: self ];
119
- }
120
- if (configuration.profiles .count > 0 ) {
121
- [self .tableView selectRowIndexes: [NSIndexSet indexSetWithIndex: (configuration.profiles.count - 1 )] byExtendingSelection: NO ];
117
+ if (configuration.profiles .count > 0 ) {
118
+ [self .tableView selectRowIndexes: [NSIndexSet indexSetWithIndex: (configuration.profiles.count - 1 )] byExtendingSelection: NO ];
119
+ }
120
+ [self loadCurrentProfile ];
121
+ if (configuration.current > selection) {
122
+ // select the original profile
123
+ configuration.current = configuration.current - 1 ;
124
+ }
122
125
}
123
126
}
124
127
@@ -196,6 +199,7 @@ - (IBAction)OK:(id)sender {
196
199
if ([self saveCurrentProfile ]) {
197
200
[self saveSettings ];
198
201
[ShadowsocksRunner reloadConfig ];
202
+ [self .delegate configurationDidChange ];
199
203
[self .window performClose: self ];
200
204
} else {
201
205
[self shakeWindow ];
0 commit comments