Repository: alacritty/alacritty
File: alacritty/src/config/ui_config.rs (Rust)

Code before:
        }
    }
}

impl UiConfig {
    /// Derive [`TermConfig`] from the config.
    pub fn term_options(&self) -> TermConfig {
        TermConfig {
            semantic_escape_chars: self.selection.semantic_escape_chars.clone(),
            scrolling_history: self.scrolling.history() as usize,
            vi_mode_cursor_style: self.cursor.vi_mode_style(),
            default_cursor_style: self.cursor.style(),
            osc52: self.terminal.osc52.0,
            kitty_keyboard: true,
        }
    }

    /// Derive [`PtyOptions`] from the config.
    pub fn pty_config(&self) -> PtyOptions {
        let shell = self.shell.clone().map(Into::into);
        PtyOptions {
            shell,
            working_directory: self.working_directory.clone(),
            hold: false,
            #[cfg(not(windows))]
            env: self.env.clone(),
        }
    }

    /// Generate key bindings for all keyboard hints.
    pub fn generate_hint_bindings(&mut self) {
        // Check which key bindings is most likely to be the user's configuration.
        //
        // Both will be non-empty due to the presence of the default keybindings.
        let key_bindings = if let Some(key_bindings) = self.key_bindings.as_mut() {
            &mut key_bindings.0
        } else {
            &mut self.keyboard.bindings.0
        };

        for hint in &self.hints.enabled {
            let binding = match &hint.binding {
                Some(binding) => binding,
                None => continue,
            };

            let binding = KeyBinding {
                trigger: binding.key.clone(),
                mods: binding.mods.0,
                mode: binding.mode.mode,
                notmode: binding.mode.not_mode,

Review comment (suggestion):
This should be _empty_ since we set env for alacritty iself so it's inherited.

The rest could be a bit confusing with the way things work currently.

Code after:
        }
    }
}

impl UiConfig {
    /// Derive [`TermConfig`] from the config.
    pub fn term_options(&self) -> TermConfig {
        TermConfig {
            semantic_escape_chars: self.selection.semantic_escape_chars.clone(),
            scrolling_history: self.scrolling.history() as usize,
            vi_mode_cursor_style: self.cursor.vi_mode_style(),
            default_cursor_style: self.cursor.style(),
            osc52: self.terminal.osc52.0,
            kitty_keyboard: true,
        }
    }

    /// Derive [`PtyOptions`] from the config.
    pub fn pty_config(&self) -> PtyOptions {
        let shell = self.shell.clone().map(Into::into);
        PtyOptions {
            shell,
            working_directory: self.working_directory.clone(),
            hold: false,
            env: HashMap::new(),
        }
    }

    /// Generate key bindings for all keyboard hints.
    pub fn generate_hint_bindings(&mut self) {
        // Check which key bindings is most likely to be the user's configuration.
        //
        // Both will be non-empty due to the presence of the default keybindings.
        let key_bindings = if let Some(key_bindings) = self.key_bindings.as_mut() {
            &mut key_bindings.0
        } else {
            &mut self.keyboard.bindings.0
        };

        for hint in &self.hints.enabled {
            let binding = match &hint.binding {
                Some(binding) => binding,
                None => continue,
            };

            let binding = KeyBinding {
                trigger: binding.key.clone(),
                mods: binding.mods.0,
                mode: binding.mode.mode,
                notmode: binding.mode.not_mode,
                action: Action::Hint(hint.clone()),