Open Bug 507653 Opened 11 years ago Updated 8 years ago

Smartly truncate URLs in autocomplete window


(Camino Graveyard :: Location Bar & Autocomplete, enhancement)

Not set


(Not tracked)


(Reporter:, Assigned:




(1 file)

3.49 KB, patch
: review-
Details | Diff | Splinter Review
User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Safari/528.17
Build Identifier: 

Instead of using NSLineBreakByTruncatingTail or NSLineBreakByTruncatingMiddle in the AutoCompleteCell to deal with long URLs, we should cut out the least pertinent parts of the URL first. For example:

should become (as the window gets smaller and smaller):

When the URL has been shortened as much as possible in this way, revert to using NSLineBreakByTruncatingMiddle on the last form of the URL;


Any other suggestions are welcome.

Reproducible: Always
Assignee: nobody →
Ever confirmed: true
Attached patch Patch 1Splinter Review
Attachment #392172 - Flags: review?(stuart.morgan+bugzilla)
Comment on attachment 392172 [details] [diff] [review]
Patch 1

First, as a general note, make this whole thing a category method in NSString+Utils, taking the string, attributes, and target width (just make it clear in the comment for it that it may return a string that is longer than the target width if it can't do a good job trimming). That will also let you switch from heavily nested ifs to early returns.

>+      if (scheme) {
>+        NSRange schemeRange = [url rangeOfString:scheme];
>+        url = [url substringFromIndex:NSMaxRange(schemeRange) + 3];

I know this was my suggestion, but I'm starting to have second thoughts. Do we really want to remove the ability to distinguish between http and https versions of a page? And if we only do http, https URLs will probably look really weird.

>+                path = [NSString stringWithFormat:@"%@%@%@", [path substringToIndex:startLoc], [path rangeOfString:@"â¦"].location == NSNotFound ? @"â¦" : @"", [path substringFromIndex:endLoc]];

No non-ASCII in source files; use ellipsisString from our NSString+Utils.
Attachment #392172 - Flags: review?(stuart.morgan+bugzilla) → review-
Stuart, how far from shippable was this patch?  Obviously it needs to be restructured to fit your comments, but was it otherwise doing the right thing?  This is another item that came up in forum feedback.
Flags: camino2.1.2?
Flags: camino2.1.1?
Flags: camino2.1.1-
You need to log in before you can comment on or make changes to this bug.