fix(core): improve continuous word matches detection

This commit is contained in:
Federico Terzi 2021-04-18 12:33:53 +02:00
parent 04f1449046
commit 82096ad9fa
3 changed files with 20 additions and 19 deletions

View File

@ -40,6 +40,7 @@ pub enum Event {
RenderingRequested(render::RenderingRequestedEvent),
Rendered(render::RenderedEvent),
MatchInjected,
// Effects
TriggerCompensation(effect::TriggerCompensationEvent),

View File

@ -50,10 +50,14 @@ impl<'a> Middleware for ActionMiddleware<'a> {
fn next(&self, event: Event, dispatch: &mut dyn FnMut(Event)) -> Event {
match &event {
Event::Rendered(m_event) => Event::TextInject(TextInjectRequest {
text: m_event.body.clone(),
force_mode: self.match_info_provider.get_force_mode(m_event.match_id),
}),
Event::Rendered(m_event) => {
dispatch(Event::MatchInjected);
Event::TextInject(TextInjectRequest {
text: m_event.body.clone(),
force_mode: self.match_info_provider.get_force_mode(m_event.match_id),
})
}
Event::CursorHintCompensation(m_event) => {
Event::KeySequenceInject(KeySequenceInjectRequest {
keys: (0..m_event.cursor_hint_back_count)

View File

@ -120,28 +120,24 @@ impl<'a, State> Middleware for MatcherMiddleware<'a, State> {
}
fn is_event_of_interest(event: &Event) -> bool {
if let Event::Keyboard(keyboard_event) = &event {
if keyboard_event.status == Status::Pressed {
return true;
}
match event {
Event::Keyboard(keyboard_event) if keyboard_event.status == Status::Pressed => true,
// TODO: handle mouse
Event::MatchInjected => true,
_ => false,
}
// TODO: handle mouse
false
}
fn convert_to_matcher_event(event: &Event) -> Option<MatcherEvent> {
if let Event::Keyboard(keyboard_event) = event {
return Some(MatcherEvent::Key {
match event {
Event::Keyboard(keyboard_event) => Some(MatcherEvent::Key {
key: keyboard_event.key.clone(),
chars: keyboard_event.value.clone(),
});
}),
Event::MatchInjected => Some(MatcherEvent::VirtualSeparator),
// TODO: mouse event should act as separator
_ => None,
}
// TODO: mouse event should act as separator
None
}
fn is_invalidating_key(key: &Key) -> bool {