env: check cheaper condition first

This commit is contained in:
Johannes Altmanninger
2025-12-30 08:38:06 +01:00
parent 5b3b825ab2
commit 20427ff1f6
2 changed files with 11 additions and 7 deletions

View File

@@ -8,7 +8,8 @@
use crate::prelude::*;
use crate::reader::{
reader_change_cursor_end_mode, reader_change_cursor_selection_mode, reader_change_history,
reader_schedule_prompt_repaint, reader_set_autosuggestion_enabled, reader_set_transient_prompt,
reader_current_data, reader_schedule_prompt_repaint, reader_set_autosuggestion_enabled,
reader_set_transient_prompt,
};
use crate::screen::{
IS_DUMB, LAYOUT_CACHE_SHARED, ONLY_GRAYSCALE, screen_set_midnight_commander_hack,
@@ -215,11 +216,14 @@ pub fn env_dispatch_var_change(key: &wstr, vars: &EnvStack) {
dispatch_table.dispatch(key, vars);
}
if string_prefixes_string(L!("fish_color_"), key)
// TODO Don't re-exec prompt when only pager color changed.
|| string_prefixes_string(L!("fish_pager_color_"), key)
{
reader_schedule_prompt_repaint();
// TODO(MSRV>=1.88): if-let
if let Some(data) = reader_current_data() {
if string_prefixes_string(L!("fish_color_"), key) || {
// TODO Don't re-exec prompt when only pager color changed.
string_prefixes_string(L!("fish_pager_color_"), key)
} {
data.schedule_prompt_repaint();
}
}
}

View File

@@ -1617,7 +1617,7 @@ pub fn mouse_left_click(&mut self, click_position: ViewportPosition) {
}
}
fn schedule_prompt_repaint(&mut self) {
pub fn schedule_prompt_repaint(&mut self) {
if self.force_exec_prompt_and_repaint {
return;
}