Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: allow sorting by dirname / filename in interactive mode #275

Merged
merged 2 commits into from
Jan 27, 2025

Conversation

joehasson
Copy link
Contributor

Hi! This PR closes #269 by allowing users to toggle ascending / descending sort by name using the 'n' hotkey. A couple of notes on the design here, illustrated in the screen recording below.

  • When the sort is first toggled, it is ascending by default, unlike the other sort modes, which default to descending (presumably users want to sort A-Z rather than Z-A)
  • Entries are sorted first by type (directories before files) and lexicographically by name within each type. My thinking here is that users are likely sorting alphabetically so that they can navigate more easily. This is in line with how other command line tools like vim's file explorer perform sort by name.
  • Names are sorted lexicographically rather than with a natural sort as suggested in Enhancement request: sort by name natually #126. Again this seems to be in line with how other tools sort by name, and is simpler to implement.
  • The name column doesn't get highlighted in green once we choose to sort on it. I had a go at implementing this but think it may be more confusing than helpful given that names are highlighted to show which entries have / haven't been marked?
dua-sort-by-name.mp4

Copy link
Owner

@Byron Byron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great work, thanks a lot!

I will release it shortly!

@Byron Byron merged commit 364f732 into Byron:main Jan 27, 2025
2 checks passed
@Byron
Copy link
Owner

Byron commented Jan 27, 2025

@EliahKagan I just wanted to share with you a finding I made just now. It's definitely a bug to be fixed in gitoxide at some point, maybe it's something that can be researched. My feeling is that it's something about how the dirwalk translates filesystem entries to precomposed unicode to look it up in the index (or its failure to do so).

dua-cli ( feat/interactive-mode-sort-by-name) [$?]
❯ gst
On branch feat/interactive-mode-sort-by-name
nothing to commit, working tree clean

dua-cli ( feat/interactive-mode-sort-by-name) [$?]
❯ gix status
 09:48:49 status done 111.0 files in 0.00s (39.3K files/s)
  ? tests/fixtures/right-to-left/نَاقَشَةُ سُبُلِ اِسْتِخْدَامِ اللُّغَةِ فِي النُّظُمِ الْقَائِمَةِ وَفِيم يَخُصَّ التَّطْبِيقَاتُ الْحاسُوبِيَّةُ،

dua-cli ( feat/interactive-mode-sort-by-name) [$?]
❯ gix clean
WOULD remove tests/fixtures/right-to-left/نَاقَشَةُ سُبُلِ اِسْتِخْدَامِ اللُّغَةِ فِي النُّظُمِ الْقَائِمَةِ وَفِيم يَخُصَّ التَّطْبِيقَاتُ الْحاسُوبِيَّةُ،

Skipped 1 directory - show with -d; Skipped 2 expendable entries - show with -x; Skipped 2 precious entries - show with -p

What seems to happen here is that the index lookup should tell gix-dir that the file is in the index and thus tracked, but the lookup fails.

@Byron
Copy link
Owner

Byron commented Jan 27, 2025

And here is the new release: https://github.com/Byron/dua-cli/releases/tag/v2.30.0 .

@EliahKagan
Copy link

Did this start in gitoxide recently? Or is it just that it was recently discovered?

@Byron
Copy link
Owner

Byron commented Jan 27, 2025

I just discovered it, and would be thinking the issue is there from day one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FR: Add "sort by name" in interactive mode
3 participants