Skip to content

Add sort hotkeys and fix reverse reset on field switch - #5145

Open
ChelpanovIlya wants to merge 2 commits into
MidnightCommander:masterfrom
ChelpanovIlya:pr/sort-hotkeys
Open

Add sort hotkeys and fix reverse reset on field switch#5145
ChelpanovIlya wants to merge 2 commits into
MidnightCommander:masterfrom
ChelpanovIlya:pr/sort-hotkeys

Conversation

@ChelpanovIlya

Copy link
Copy Markdown
Contributor

Proposed changes

Bind Alt+n/x/m/z to SortByName/SortByExt/SortByMTime/SortBySize in all keymap files. Each hotkey toggles ascending/descending when the panel is already sorted by that field.

Fix panel_set_sort_type_by_id() to reset sort_info.reverse to FALSE when switching to a new sort field, matching the behavior of mouse_sort_col(). Previously the reverse flag was carried over from the previous field.

Checklist

  • I have referenced the issue(s) resolved by this PR (if any)
  • I have signed-off my contribution with git commit --amend -s
  • Lint and unit tests pass locally with my changes (make indent && make check)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)

@github-actions github-actions Bot added needs triage Needs triage by maintainers prio: medium Has the potential to affect progress labels Aug 27, 2026
@github-actions github-actions Bot added this to the Future Releases milestone Aug 27, 2026
@ossilator

Copy link
Copy Markdown
Contributor

please split this into two commits and force push.

@mc-worker

mc-worker commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Alt-n is already used to navigate in the command line history (see HistoryNext in the section [Input]).

Please move the sort_info.reverse related issue to the separate commit or even to the separate PR.

panel_set_sort_type_by_id() did not reset sort_info.reverse to FALSE
when switching to a new sort field. This caused the reverse flag from
the previous sort field to carry over to the new one.

For example, if the panel was sorted by name in reverse order and the
user switched to sort by size, the size sort would also be reversed.

This behavior was inconsistent with mouse_sort_col() which already
reset reverse to FALSE when clicking a different column header.

Fix by setting panel->sort_info.reverse = FALSE when switching to a
new sort field, matching the mouse click behavior.

Signed-off-by: ChelpanovIlya <ChelpanovIlya@users.noreply.github.com>
@ChelpanovIlya
ChelpanovIlya force-pushed the pr/sort-hotkeys branch 2 times, most recently from c89d928 to 65fd81c Compare August 28, 2026 17:32
Bind sort commands in mc.default.keymap using Alt+Shift+key to avoid
conflicts with existing bindings (e.g. Alt+n is HistoryNext):
- SortByName = alt-shift-n
- SortByExt = alt-shift-x
- SortByMTime = alt-shift-m
- SortBySize = alt-shift-z

Each hotkey toggles ascending/descending when the panel is already
sorted by that field. Previously these commands existed but had no
default keybindings.

Signed-off-by: ChelpanovIlya <ChelpanovIlya@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs triage Needs triage by maintainers prio: medium Has the potential to affect progress

Development

Successfully merging this pull request may close these issues.

3 participants