[txmt-dev] Make the FileChooser's extension handling better

Caleb Land caleb.land at gmail.com
Thu Jan 24 21:28:44 UTC 2013


Hi, 

Before submitting another pull request for this, I figured I'd send a message to the list.

https://github.com/caleb/textmate/commit/12f89549056957e6ee23f34c1badc5972ca5055c

We wanted a solution that does the following:

* Matches extensions exactly
* Matches multiple extensions when either one or more of those extensions is specified

== The problem with a simple solution using #find ==

Unfortunately a simple substring "std::string#find" solution won't work for this since we want to match extensions exactly.

A simple substring search for ".m" would match ".mdown".


== The solution is to treat each extension as a separate thing ==

This solution splits the extensions string (e.g. ".html.erb") on periods into a vector.

Then we ensure that all of the extensions that are being searched for are included in the candidate extensions vector.

As for files with names like: "com.macromates.TextMate.preview.plist" this patch makes searching for it by ".plist" extension work, but that's as far as it goes.

You can only find "com.macromates.TextMate.preview.plist" if you search for the file name without the periods (i.e. you can find it with "com macromates.plist", but not with "com.macromates.plist")

If we think of periods in the FileChooser as a special character, like we do "@" and ":" (i.e. it says "put the chooser into extension finding mode"), then I think it's okay leaving it like that.

Let me know what you think.

-Caleb

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate-dev/attachments/20130124/59b15b0c/attachment.html>


More information about the textmate-dev mailing list