aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPCharsetCollationHelper.m
diff options
context:
space:
mode:
authorAbhi Beckert <abhi@Twist-of-Lemon-2.local>2015-05-16 08:06:06 +1000
committerAbhi Beckert <abhi@Twist-of-Lemon-2.local>2015-05-16 08:06:06 +1000
commit57a6f6c73bdaa202164645370d37fcbe5d14a092 (patch)
treedd30aa6156064f1d4c0e10ea87059625470fc2f9 /Source/SPCharsetCollationHelper.m
parentb5e972f4504043dfb9c358e272e93fb59ae2127f (diff)
parent0f0c43eb74408b6a65a42e2c6fd46f4142ef8e3f (diff)
downloadsequelpro-57a6f6c73bdaa202164645370d37fcbe5d14a092.tar.gz
sequelpro-57a6f6c73bdaa202164645370d37fcbe5d14a092.tar.bz2
sequelpro-57a6f6c73bdaa202164645370d37fcbe5d14a092.zip
Merge remote-tracking branch 'sequelpro/master'
Diffstat (limited to 'Source/SPCharsetCollationHelper.m')
-rw-r--r--Source/SPCharsetCollationHelper.m15
1 files changed, 9 insertions, 6 deletions
diff --git a/Source/SPCharsetCollationHelper.m b/Source/SPCharsetCollationHelper.m
index 14b0a987..378fb7cf 100644
--- a/Source/SPCharsetCollationHelper.m
+++ b/Source/SPCharsetCollationHelper.m
@@ -133,6 +133,8 @@
if (([encodings count] > 0) && [serverSupport supportsPost41CharacterSetHandling]) {
+ NSUInteger utf8encounters = 0;
+
for (NSDictionary *encoding in encodings)
{
NSString *charsetId = [encoding objectForKey:@"CHARACTER_SET_NAME"];
@@ -146,12 +148,9 @@
if(selectedCharset && [charsetId isEqualToString:selectedCharset])
selectedRef = menuItem;
- // If the UTF8 entry has been encountered, promote it to the top of the list
- if (promoteUTF8 && [charsetId isEqualToString:@"utf8"]) {
- [[charsetButton menu] insertItem:[menuItem autorelease] atIndex:0];
- //only add a separator if there actually are more items other than utf8 (might not be true for mysql forks)
- if([encodings count] > 1)
- [[charsetButton menu] insertItem:[NSMenuItem separatorItem] atIndex:1];
+ // If an UTF8 entry has been encountered, promote it to the top of the list
+ if (promoteUTF8 && [charsetId hasPrefix:@"utf8"]) {
+ [[charsetButton menu] insertItem:[menuItem autorelease] atIndex:(utf8encounters++)];
}
else {
[[charsetButton menu] addItem:[menuItem autorelease]];
@@ -159,6 +158,10 @@
}
+ //only add a separator if there actually are more items other than utf8 (might not be true for mysql forks)
+ if(utf8encounters && [encodings count] > utf8encounters)
+ [[charsetButton menu] insertItem:[NSMenuItem separatorItem] atIndex:utf8encounters];
+
[charsetButton setEnabled:YES];
}