Repository: alacritty/alacritty
File: alacritty/src/input/keyboard.rs (Rust)

Code before:
            self.ctx.write_to_pty(bytes);
        }
    }

    /// Check whether we should try to build escape sequence for the [`KeyEvent`].
    fn should_build_sequence(
        key: &KeyEvent,
        text: &str,
        mode: TermMode,
        mods: ModifiersState,
    ) -> bool {
        if mode.contains(TermMode::REPORT_ALL_KEYS_AS_ESC) {
            return true;
        }

        let disambiguate = if mode.contains(TermMode::DISAMBIGUATE_ESC_CODES) {
            let on_numpad = key.location == KeyLocation::Numpad;
            let is_escape = key.logical_key == Key::Named(NamedKey::Escape);
            is_escape || (!mods.is_empty() && mods != ModifiersState::SHIFT) || on_numpad
        } else {
            false
        };

        match key.logical_key {
            _ if disambiguate => true,
            // Exclude all the named keys unless they have textual representation.
            Key::Named(named) => named.to_text().is_none(),
            _ => text.is_empty(),
        }
    }

    /// Whether we should send `ESC` due to `Alt` being pressed.
    #[cfg(not(target_os = "macos"))]
    fn alt_send_esc(&mut self) -> bool {
        self.ctx.modifiers().state().alt_key()
    }

    #[cfg(target_os = "macos")]
    fn alt_send_esc(&mut self) -> bool {
        let option_as_alt = self.ctx.config().window.option_as_alt();
        self.ctx.modifiers().state().alt_key()
            && (option_as_alt == OptionAsAlt::Both
                || (option_as_alt == OptionAsAlt::OnlyLeft
                    && self.ctx.modifiers().lalt_state() == ModifiersKeyState::Pressed)
                || (option_as_alt == OptionAsAlt::OnlyRight
                    && self.ctx.modifiers().ralt_state() == ModifiersKeyState::Pressed))
    }

    /// Attempt to find a binding and execute its action.
    ///
    /// The provided mode, mods, and key must match what is allowed by a binding

Review comment (suggestion):
This should be a _common fallback_ and not `else` clause, otherwise `Arrow` will be omitted (note that you can't face it in vim, because cursor keys, so it's handled before everything else). 

Code after:
            self.ctx.write_to_pty(bytes);
        }
    }

    /// Check whether we should try to build escape sequence for the [`KeyEvent`].
    fn should_build_sequence(
        key: &KeyEvent,
        text: &str,
        mode: TermMode,
        mods: ModifiersState,
    ) -> bool {
        if mode.contains(TermMode::REPORT_ALL_KEYS_AS_ESC) {
            return true;
        }

        let disambiguate = mode.contains(TermMode::DISAMBIGUATE_ESC_CODES)
            && (key.logical_key == Key::Named(NamedKey::Escape)
                || (!mods.is_empty() && mods != ModifiersState::SHIFT)
                || key.location == KeyLocation::Numpad);

        match key.logical_key {
            _ if disambiguate => true,
            // Exclude all the named keys unless they have textual representation.
            Key::Named(named) => named.to_text().is_none(),
            _ => text.is_empty(),
        }
    }

    /// Whether we should send `ESC` due to `Alt` being pressed.
    #[cfg(not(target_os = "macos"))]
    fn alt_send_esc(&mut self) -> bool {
        self.ctx.modifiers().state().alt_key()
    }

    #[cfg(target_os = "macos")]
    fn alt_send_esc(&mut self) -> bool {
        let option_as_alt = self.ctx.config().window.option_as_alt();
        self.ctx.modifiers().state().alt_key()
            && (option_as_alt == OptionAsAlt::Both
                || (option_as_alt == OptionAsAlt::OnlyLeft
                    && self.ctx.modifiers().lalt_state() == ModifiersKeyState::Pressed)
                || (option_as_alt == OptionAsAlt::OnlyRight
                    && self.ctx.modifiers().ralt_state() == ModifiersKeyState::Pressed))
    }

    /// Attempt to find a binding and execute its action.
    ///
    /// The provided mode, mods, and key must match what is allowed by a binding
    /// for its action to be executed.
    fn process_key_bindings(&mut self, key: &KeyEvent) -> bool {
        let mode = BindingMode::new(self.ctx.terminal().mode(), self.ctx.search_active());