fresh icon indicating copy to clipboard operation
fresh copied to clipboard

Re-sort file tree when sort mode changes

Open lorenjphillips opened this issue 3 weeks ago • 4 comments

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!

lorenjphillips avatar Dec 07 '25 04:12 lorenjphillips

Where in the UI can I see the effect of this change?

sinelaw avatar Dec 07 '25 07:12 sinelaw

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?

lorenjphillips avatar Dec 07 '25 18:12 lorenjphillips

Gotcha I'll take a look at adding sort to the file explorer ui

sinelaw avatar Dec 08 '25 10:12 sinelaw

Thanks so much!! Let me know if you would like any more changes in the PR for the sort!!

lorenjphillips avatar Dec 08 '25 23:12 lorenjphillips