Sort directory listings with directories before files #27
Loading…
Reference in New Issue
No description provided.
Delete Branch "Russtopia/molly-brown:sort-dirs-first"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This patch improves the readability of directory listings, by grouping all directories together at the top, then files. The other sort criteria are otherwise still applied (ie., all dirs sorted by Date, then files sorted by Date, or whatever according to the config file).
Perhaps it could be refactored to avoid the almost-repeated logic in each sort case; I can look at that if you think it's gross 😃
Bump (promise I won't do it again, just wondering if this repo is alive at all)
I prefer files and dirs mixed.
Am I really the last living creature with this preference?
Fair enough :) I can rework the patch to make it a preference when the server is launched, to allow either behaviour.
a4873da190
to2dcaf941e4
Added new
DirectoriesFirst
config flag, defaults tofalse
to preserve current behaviour onmaster
Bump. 8 months, anyone have an opinion on this config feature?
Sorry for the phenomenally slow response time on this, and thanks for the help!
I'm happy to include this functionality, as something which can be toggled on or off by the user. I do think it could be done a little better. If, after over a year, you don't really care anymore and want to tell me to take a hike, then that's perfectly reasonable (really!), and I'll accept the PR as it is and do some tidying myself.
But if you are still willing to work on this: yeah, I think the repeated logic is gross, like you said, but thankfully also easily avoidable:
sort.SliceStable()
is a stable sort, i.e. if two items compare as equal it will leave them in their original order. So you should be able to just do one sort by name/size/time and then a second sort after that which puts directories before files. Much neater!Also, all the other config options related to the directory list generation begin with
Directory
and it'd be kinda nice to keep that consistency. Maybe this option could beDirectoryDirsFirst
?Hi there. I went ahead and merged this PR (didn't use the Tildegit interface to do it as I had pushed other changes which prevented an automatic merge, so I will close this manually), and then refactored it as above to do the sorting in two passes. It seems to work nicely and is a lot more concise.
Sorry if this seems impatient, I know that I made you wait years and then only gave you weeks. I'm just trying to give Molly Brown some much needed love and move through the long list of neglected issues quickly.
Thanks again for this contribution, I agree that turning this option on improves the readability of the directory listings!
Hi, hah I am just as guilty as you I suppose for not paying attention 😃 - glad to be able to contribute in a minor way. I see there was a recent refactor on the dirlist code; looks like that repetitive code was nicely done away with.
Cheers.
Pull request closed