Repository: alacritty/alacritty
File: alacritty/src/event.rs (Rust)

Code before:
            | GlutinEvent::MainEventsCleared
            | GlutinEvent::LoopDestroyed => true,
            _ => false,
        }
    }

    pub fn reload_config<T>(
        path: &PathBuf,
        processor: &mut input::Processor<T, ActionContext<N, T>>,
    ) where
        T: EventListener,
    {
        processor.ctx.message_buffer.remove_target(LOG_TARGET_CONFIG);
        processor.ctx.display_update_pending.message_buffer = Some(());

        let config = match config::reload_from(&path) {
            Ok(config) => config,
            Err(_) => return,
        };

        let options = Options::new();
        let config = options.into_config(config);

        processor.ctx.terminal.update_config(&config);

        // Reload cursor if we've changed it's thickness
        if (processor.ctx.config.cursor.thickness() - config.cursor.thickness()).abs()
            > std::f32::EPSILON
        {
            processor.ctx.display_update_pending.cursor = Some(());
        }

        if processor.ctx.config.font != config.font {
            // Do not update font size if it has been changed at runtime
            if *processor.ctx.font_size == processor.ctx.config.font.size {
                *processor.ctx.font_size = config.font.size;
            }

            let font = config.font.clone().with_size(*processor.ctx.font_size);
            processor.ctx.display_update_pending.font = Some(font);
        }

        #[cfg(not(any(target_os = "macos", windows)))]
        {
            if processor.ctx.event_loop.is_wayland() {
                processor.ctx.window.set_wayland_theme(&config.colors);
            }
        }

        *processor.ctx.config = config;


Review comment (suggestion):
Currently we reload the entire font. So this isn't really true.

On the other hand, we're not really reloading anything here, we are just requesting something to change and what actually changes is up to the handler.

So depending on where we go with the root problem of the handler doing kind of nasty stuff, I'd like to revisit this.

Code after:
        }
    }

    pub fn reload_config<T>(
        path: &PathBuf,
        processor: &mut input::Processor<T, ActionContext<N, T>>,
    ) where
        T: EventListener,
    {
        processor.ctx.message_buffer.remove_target(LOG_TARGET_CONFIG);
        processor.ctx.display_update_pending.message_buffer = true;

        let config = match config::reload_from(&path) {
            Ok(config) => config,
            Err(_) => return,
        };

        let options = Options::new();
        let config = options.into_config(config);

        processor.ctx.terminal.update_config(&config);

        // Reload cursor if we've changed its thickness
        if (processor.ctx.config.cursor.thickness() - config.cursor.thickness()).abs()
            > std::f64::EPSILON
        {
            processor.ctx.display_update_pending.cursor = true;
        }

        if processor.ctx.config.font != config.font {
            // Do not update font size if it has been changed at runtime
            if *processor.ctx.font_size == processor.ctx.config.font.size {
                *processor.ctx.font_size = config.font.size;
            }

            let font = config.font.clone().with_size(*processor.ctx.font_size);
            processor.ctx.display_update_pending.font = Some(font);
        }

        #[cfg(not(any(target_os = "macos", windows)))]
        {
            if processor.ctx.event_loop.is_wayland() {
                processor.ctx.window.set_wayland_theme(&config.colors);
            }
        }

        *processor.ctx.config = config;

        processor.ctx.terminal.dirty = true;
    }