Re-sort file tree when sort mode changes
Noticed the file tree sort mode wasnt actually re-sorting when you switched modes - you had to collapse and re-expand directories to see the change. Found the TODO comment at view.rs:268 and figured I'd take a crack at it.
Changes
- Added
SortMode::comparator()that returns the right comparison fn for each mode - Added
FileTree::sort_all_nodes()to re-sort all expanded directories - Updated
set_sort_mode()to trigger the resort
Testing
- added two tests for the sort mode switching behavior
- ran
cargo test file_tree- all 36 tests pass - built with
cargo build --lib, no new warnings
Let me know if you want me to change anythign!
Where in the UI can I see the effect of this change?
Thanks for reviewing this! sort mode isn't wired up to any keybinding yet... I added the fix first figuring the UI part would be simpler to add on top, happy to add what I built for myself but figured you may be opinionated about UI :)
Where in the UI can I see the effect of this change?
Gotcha I'll take a look at adding sort to the file explorer ui
Thanks so much!! Let me know if you would like any more changes in the PR for the sort!!