Yes, I can try it, but please also let me change the searchText, too.

-------- Ursprüngliche Nachricht --------
Von: Chema Balsas <notifications@github.com> 
Datum: 13.10.2013  23:31  (GMT+01:00) 
An: jbalsas/brackets-localization-workflow <brackets-localization-workflow@noreply.github.com> 
Cc: Marcel Gerber <mg.hain@gmx.de> 
Betreff: Re: [brackets-localization-workflow] Automatically find the base dir (#4) 
 
In main.js:

> +        FileIndexManager.getFileInfoList("all").done(function (allFiles) {
> +            var i = 0, shortest, shortestLen;
> +            var filtered = allFiles.filter(function (item) {
> +                return (item.fullPath.indexOf(searchFor) === item.fullPath.length - searchFor.length);
> +            });
> +            if (filtered.length === 1) {
> +                baseDir = FileUtils.getDirectoryPath(filtered[0].fullPath);
> +            } else if (filtered.length > 1) {
> +                baseDir = filtered.reduce(function (a, b) {
> +                    return a.fullPath.length < b.fullPath.length ? a : b;
> +                });
> +                baseDir = FileUtils.getDirectoryPath(baseDir.fullPath);
> +            } else {
> +                baseDir = filtered;
> +            }
> +        }).then(function () {
Maybe it wasn't working because you were using done in the first place.

done returns the same promise, so the next then just gets chain to the original one and executed right after the first done handler finishes.

In contrast, then returns a new promise that is resolved with the return value of the filter it receives.

I can merge it as is and work on it, or wait for you to do it if you want to give it a try. As you'd prefer :)

—
Reply to this email directly or view it on GitHub.