From 631f7869a5a40262a46e1da4ea4ab1ec1541887d Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 16 Jan 2022 20:59:51 -0700 Subject: [PATCH] launcher: consistently order entries --- wezterm-gui/src/overlay/launcher.rs | 5 ++++- wezterm-input-types/src/lib.rs | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/wezterm-gui/src/overlay/launcher.rs b/wezterm-gui/src/overlay/launcher.rs index f720f281e..e9e5144d8 100644 --- a/wezterm-gui/src/overlay/launcher.rs +++ b/wezterm-gui/src/overlay/launcher.rs @@ -18,6 +18,7 @@ use mux::tab::TabId; use mux::termwiztermtab::TermWizTerminal; use mux::window::WindowId; use mux::Mux; +use std::collections::BTreeMap; use termwiz::cell::{AttributeChange, CellAttributes}; use termwiz::color::ColorAttribute; use termwiz::input::{InputEvent, KeyCode, KeyEvent, MouseButtons, MouseEvent}; @@ -302,7 +303,9 @@ impl LauncherState { if args.flags.contains(LauncherFlags::KEY_ASSIGNMENTS) { let input_map = InputMap::new(&config); let mut key_entries: Vec = vec![]; - for ((keycode, mods), assignment) in input_map.keys { + // Give a consistent order to the entries + let keys: BTreeMap<_, _> = input_map.keys.into_iter().collect(); + for ((keycode, mods), assignment) in keys { if matches!( &assignment, KeyAssignment::ActivateTabRelative(_) | KeyAssignment::ActivateTab(_) diff --git a/wezterm-input-types/src/lib.rs b/wezterm-input-types/src/lib.rs index 48a373d98..91ff52c0a 100644 --- a/wezterm-input-types/src/lib.rs +++ b/wezterm-input-types/src/lib.rs @@ -14,7 +14,7 @@ pub type ScreenPoint = euclid::Point2D; /// Which key is pressed. Not all of these are probable to appear /// on most systems. A lot of this list is @wez trawling docs and /// making an entry for things that might be possible in this first pass. -#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, Ord, PartialOrd)] pub enum KeyCode { /// The decoded unicode character Char(char), @@ -353,7 +353,7 @@ impl ToString for Modifiers { /// These keycodes identify keys based on their physical /// position on an ANSI-standard US keyboard. -#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq, Hash, Copy)] +#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq, Hash, Copy, Ord, PartialOrd)] pub enum PhysKeyCode { A, B,