From f07ff326b526d1343f826b12b0153c8aaeada8cb Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Fri, 30 Apr 2021 17:06:26 +0200 Subject: [PATCH] style(core): expand some TODO comments --- espanso/src/cli/worker/engine/executor/event_injector.rs | 2 -- espanso/src/cli/worker/engine/executor/key_injector.rs | 2 -- espanso/src/cli/worker/engine/source/modifier.rs | 5 ++++- espanso/src/engine/process/middleware/delay_modifiers.rs | 9 ++++++--- espanso/src/main.rs | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/espanso/src/cli/worker/engine/executor/event_injector.rs b/espanso/src/cli/worker/engine/executor/event_injector.rs index ef4be7e..e06bbe6 100644 --- a/espanso/src/cli/worker/engine/executor/event_injector.rs +++ b/espanso/src/cli/worker/engine/executor/event_injector.rs @@ -39,8 +39,6 @@ impl <'a> TextInjector for EventInjectorAdapter<'a> { } fn inject_text(&self, text: &str) -> anyhow::Result<()> { - // TODO: wait for modifiers release - // Handle CRLF or LF line endings correctly let split_sequence = if text.contains("\r\n") { "\r\n" diff --git a/espanso/src/cli/worker/engine/executor/key_injector.rs b/espanso/src/cli/worker/engine/executor/key_injector.rs index 15a319e..8fa907e 100644 --- a/espanso/src/cli/worker/engine/executor/key_injector.rs +++ b/espanso/src/cli/worker/engine/executor/key_injector.rs @@ -33,8 +33,6 @@ impl<'a> KeyInjectorAdapter<'a> { impl<'a> KeyInjector for KeyInjectorAdapter<'a> { fn inject_sequence(&self, keys: &[crate::engine::event::input::Key]) -> anyhow::Result<()> { - // TODO: wait for modifiers release - let converted_keys: Vec<_> = keys.iter().map(convert_to_inject_key).collect(); self.injector.send_keys(&converted_keys, Default::default()) // TODO: handle options } diff --git a/espanso/src/cli/worker/engine/source/modifier.rs b/espanso/src/cli/worker/engine/source/modifier.rs index 02e40b4..3d7f63a 100644 --- a/espanso/src/cli/worker/engine/source/modifier.rs +++ b/espanso/src/cli/worker/engine/source/modifier.rs @@ -26,7 +26,10 @@ use log::warn; use crate::engine::process::ModifierStatusProvider; -// TODO: explain +/// This duration represents the maximum length for which a pressed modifier +/// event is considered valid. This is useful when the "release" event is +/// lost for whatever reason, so that espanso becomes eventually consistent +/// after a while. const MAXIMUM_MODIFIERS_PRESS_TIME_RECORD: Duration = Duration::from_secs(30); #[derive(Debug, Hash, PartialEq, Eq)] diff --git a/espanso/src/engine/process/middleware/delay_modifiers.rs b/espanso/src/engine/process/middleware/delay_modifiers.rs index cc155ef..22041bb 100644 --- a/espanso/src/engine/process/middleware/delay_modifiers.rs +++ b/espanso/src/engine/process/middleware/delay_modifiers.rs @@ -17,8 +17,6 @@ * along with espanso. If not, see . */ -// TODO: explain why this is needed - use std::{ time::{Duration, Instant}, }; @@ -28,13 +26,18 @@ use log::{trace, warn}; use super::super::Middleware; use crate::engine::event::{Event, EventType}; -// TODO: pass through config +/// Maximum time to wait for modifiers being released before +/// giving up. const MODIFIER_DELAY_TIMEOUT: Duration = Duration::from_secs(3); pub trait ModifierStatusProvider { fn is_any_modifier_pressed(&self) -> bool; } +/// This middleware is used to delay the injection of text until +/// all modifiers have been released. This is needed as otherwise, +/// injections might misbehave as pressed modifiers might alter +/// the keys being injected. pub struct DelayForModifierReleaseMiddleware<'a> { provider: &'a dyn ModifierStatusProvider, } diff --git a/espanso/src/main.rs b/espanso/src/main.rs index 5f87e36..1adbab1 100644 --- a/espanso/src/main.rs +++ b/espanso/src/main.rs @@ -201,7 +201,7 @@ fn main() { // .subcommand(install_subcommand) // .subcommand(uninstall_subcommand); - // TODO: explain that the start and restart commands are only meaningful + // TODO: explain that the register and unregister commands are only meaningful // when using the system daemon manager on macOS and Linux let matches = clap_instance.clone().get_matches();