From 2533876ad7a88d27aae366c0e6bc3844231ab99e Mon Sep 17 00:00:00 2001 From: ItsEthra <107059409+ItsEthra@users.noreply.github.com> Date: Tue, 19 Sep 2023 23:17:45 +0300 Subject: [PATCH] Hide command docs if needed --- helix-term/src/commands/typed.rs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index f38ae6bba..0a1f90a61 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -3199,20 +3199,23 @@ pub(super) fn command_mode(cx: &mut Context) { } }, ); - prompt.doc_fn = Box::new(|input: &str| { - let part = input.split(' ').next().unwrap_or_default(); - - if let Some(typed::TypableCommand { doc, aliases, .. }) = - typed::TYPABLE_COMMAND_MAP.get(part) - { - if aliases.is_empty() { - return Some((*doc).into()); + + if cx.editor.config().command_docs { + prompt.doc_fn = Box::new(|input: &str| { + let part = input.split(' ').next().unwrap_or_default(); + + if let Some(typed::TypableCommand { doc, aliases, .. }) = + typed::TYPABLE_COMMAND_MAP.get(part) + { + if aliases.is_empty() { + return Some((*doc).into()); + } + return Some(format!("{}\nAliases: {}", doc, aliases.join(", ")).into()); } - return Some(format!("{}\nAliases: {}", doc, aliases.join(", ")).into()); - } - None - }); + None + }); + } // Calculate initial completion prompt.recalculate_completion(cx.editor);