From f506116b38e27f92990e52c716c33322d850e99a Mon Sep 17 00:00:00 2001 From: Nik Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Mon, 7 Apr 2025 22:04:28 +0100 Subject: [PATCH] fix: background color The statusline and the command mode prompt will now both have the same background when the editor.statusline.merge-with-commandline option is set --- helix-term/src/commands/typed.rs | 5 +++++ helix-term/src/ui/prompt.rs | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 49864abb6..b8219bc14 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -3253,6 +3253,11 @@ pub(super) fn command_mode(cx: &mut Context) { None }); + if cx.editor.config().statusline.merge_with_commandline { + // command line prompt has the same background as the statusline when + // the statusline and the command line are merged + prompt.background = Some(cx.editor.theme.get("ui.statusline")) + } // Calculate initial completion prompt.recalculate_completion(cx.editor); diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index 1e443ce7f..d7e83d5ef 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -28,6 +28,7 @@ pub struct Prompt { prompt: Cow<'static, str>, line: String, cursor: usize, + pub background: Option, completion: Vec, selection: Option, history_register: Option, @@ -84,6 +85,7 @@ impl Prompt { selection: None, history_register, history_pos: None, + background: None, completion_fn: Box::new(completion_fn), callback_fn: Box::new(callback_fn), doc_fn: Box::new(|_| None), @@ -401,7 +403,9 @@ impl Prompt { let completion_color = theme.get("ui.menu"); let selected_color = theme.get("ui.menu.selected"); let suggestion_color = theme.get("ui.text.inactive"); - let background = theme.get("ui.background"); + let background = self + .background + .unwrap_or_else(|| theme.get("ui.background")); // completion let max_len = self