mirror of
https://github.com/gitui-org/gitui
synced 2026-05-24 09:28:21 +00:00
better help sorting
This commit is contained in:
parent
6001593a0a
commit
448b6927c3
3 changed files with 6 additions and 3 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
///
|
///
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone, PartialEq, PartialOrd, Ord, Eq)]
|
||||||
pub struct CommandText {
|
pub struct CommandText {
|
||||||
///
|
///
|
||||||
pub name: &'static str,
|
pub name: &'static str,
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,8 @@ impl HelpComponent {
|
||||||
///
|
///
|
||||||
pub fn set_cmds(&mut self, cmds: Vec<CommandInfo>) {
|
pub fn set_cmds(&mut self, cmds: Vec<CommandInfo>) {
|
||||||
self.cmds = cmds;
|
self.cmds = cmds;
|
||||||
|
self.cmds.sort_by_key(|e| e.text);
|
||||||
|
self.cmds.dedup_by_key(|e| e.text);
|
||||||
self.cmds.sort_by_key(|e| hash(&e.text.group));
|
self.cmds.sort_by_key(|e| hash(&e.text.group));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,6 +164,7 @@ impl HelpComponent {
|
||||||
txt.extend(
|
txt.extend(
|
||||||
group
|
group
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
.sorted_by_key(|e| e.order)
|
||||||
.map(|e| {
|
.map(|e| {
|
||||||
let is_selected = self.selection == processed;
|
let is_selected = self.selection == processed;
|
||||||
if is_selected {
|
if is_selected {
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ pub mod commands {
|
||||||
///
|
///
|
||||||
pub static CLOSE_POPUP: CommandText = CommandText::new(
|
pub static CLOSE_POPUP: CommandText = CommandText::new(
|
||||||
"Close [esc]",
|
"Close [esc]",
|
||||||
"close popup",
|
"close overlay (e.g commit, help)",
|
||||||
CMD_GROUP_GENERAL,
|
CMD_GROUP_GENERAL,
|
||||||
);
|
);
|
||||||
///
|
///
|
||||||
|
|
@ -90,7 +90,7 @@ pub mod commands {
|
||||||
pub static STATUS_FOCUS_RIGHT: CommandText = CommandText::new(
|
pub static STATUS_FOCUS_RIGHT: CommandText = CommandText::new(
|
||||||
"Diff [\u{2192}]", //→
|
"Diff [\u{2192}]", //→
|
||||||
"inspect file diff",
|
"inspect file diff",
|
||||||
CMD_GROUP_GENERAL,
|
CMD_GROUP_CHANGES,
|
||||||
);
|
);
|
||||||
///
|
///
|
||||||
pub static QUIT: CommandText = CommandText::new(
|
pub static QUIT: CommandText = CommandText::new(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue