From 3d0bc720994a404ba316562621dd186e3efe98c5 Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Sat, 3 Jun 2023 10:37:06 +0200 Subject: [PATCH] Place `Info::from_keymap()` contents in `keymap.infobox()`: This makes it easier later control the order in which the key events are presented. --- helix-term/src/keymap.rs | 10 +++++++++- helix-view/src/info.rs | 15 +-------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index b9e0ec1d0..973786d53 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -102,7 +102,15 @@ impl KeyTrieNode { .position(|&k| k == *keys.iter().next().unwrap()) .unwrap() }); - Info::from_keymap(self.name(), body) + + let body: Vec<_> = body + .into_iter() + .map(|(events, desc)| { + let events = events.iter().map(ToString::to_string).collect::>(); + (events.join(", "), desc) + }) + .collect(); + Info::new(self.name(), &body) } } diff --git a/helix-view/src/info.rs b/helix-view/src/info.rs index eced78e10..1503e855e 100644 --- a/helix-view/src/info.rs +++ b/helix-view/src/info.rs @@ -1,6 +1,5 @@ -use crate::input::KeyEvent; use helix_core::{register::Registers, unicode::width::UnicodeWidthStr}; -use std::{collections::BTreeSet, fmt::Write}; +use std::fmt::Write; #[derive(Debug)] /// Info box used in editor. Rendering logic will be in other crate. @@ -55,18 +54,6 @@ impl Info { } } - pub fn from_keymap(title: &str, body: Vec<(BTreeSet, &str)>) -> Self { - let body: Vec<_> = body - .into_iter() - .map(|(events, desc)| { - let events = events.iter().map(ToString::to_string).collect::>(); - (events.join(", "), desc) - }) - .collect(); - - Self::new(title, &body) - } - pub fn from_registers(registers: &Registers) -> Self { let body: Vec<_> = registers .inner()