pull/12204/merge
Nik Revenco 2025-07-25 12:11:10 +08:00 committed by GitHub
commit 1650f8b20d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 31 additions and 6 deletions

View File

@ -120,6 +120,7 @@ The `[editor.statusline]` key takes the following sub-keys:
| `mode.normal` | The text shown in the `mode` element for normal mode | `"NOR"` |
| `mode.insert` | The text shown in the `mode` element for insert mode | `"INS"` |
| `mode.select` | The text shown in the `mode` element for select mode | `"SEL"` |
| `merge-with-commandline` | If set, the command line and statusline will merge into a single line. Status text will replace the statusline briefly | `false` |
| `diagnostics` | A list of severities which are displayed for the current buffer | `["warning", "error"]` |
| `workspace-diagnostics` | A list of severities which are displayed for the workspace | `["warning", "error"]` |

View File

@ -3728,6 +3728,11 @@ pub(super) fn command_mode(cx: &mut Context) {
}
},
);
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"))
}
prompt.doc_fn = Box::new(command_line_doc);
// Calculate initial completion

View File

@ -222,7 +222,7 @@ impl EditorView {
let mut context =
statusline::RenderContext::new(editor, doc, view, is_focused, &self.spinners);
statusline::render(&mut context, statusline_area, surface);
statusline::render(&mut context, statusline_area, surface)
}
pub fn render_rulers(
@ -1501,8 +1501,15 @@ impl Component for EditorView {
_ => false,
};
// -1 for commandline and -1 for bufferline
let mut editor_area = area.clip_bottom(1);
// If merge_with_commandline option is set, then status message renders on top of the statusline, in which case we will not show the statusline
// Otherwise, status message renders in a separate line, so we give it 1 line of vertical space
let mut editor_area = area.clip_bottom(if config.statusline.merge_with_commandline {
0
} else {
1
});
// Editor area decreases by 1, to give 1 line of vertical space for bufferline
if use_bufferline {
editor_area = editor_area.clip_top(1);
}
@ -1564,9 +1571,15 @@ impl Component for EditorView {
} else {
0
};
let y_offset = if config.statusline.merge_with_commandline {
// render macros and key sequences 1 line above
1
} else {
0
};
surface.set_string(
area.x + area.width.saturating_sub(key_width + macro_width),
area.y + area.height.saturating_sub(1),
(area.y + area.height.saturating_sub(1)).saturating_sub(y_offset),
disp.get(disp.len().saturating_sub(key_width as usize)..)
.unwrap_or(&disp),
style,
@ -1578,7 +1591,7 @@ impl Component for EditorView {
.add_modifier(Modifier::BOLD);
surface.set_string(
area.x + area.width.saturating_sub(3),
area.y + area.height.saturating_sub(1),
(area.y + area.height.saturating_sub(1)).saturating_sub(y_offset),
&disp,
style,
);

View File

@ -32,6 +32,7 @@ pub struct Prompt {
prompt: Cow<'static, str>,
line: String,
cursor: usize,
pub background: Option<helix_view::theme::Style>,
// Fields used for Component callbacks and rendering:
line_area: Rect,
anchor: usize,
@ -98,6 +99,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),
@ -407,7 +409,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

View File

@ -510,6 +510,7 @@ pub struct StatusLineConfig {
pub right: Vec<StatusLineElement>,
pub separator: String,
pub mode: ModeConfig,
pub merge_with_commandline: bool,
pub diagnostics: Vec<Severity>,
pub workspace_diagnostics: Vec<Severity>,
}
@ -536,6 +537,7 @@ impl Default for StatusLineConfig {
],
separator: String::from(""),
mode: ModeConfig::default(),
merge_with_commandline: false,
diagnostics: vec![Severity::Warning, Severity::Error],
workspace_diagnostics: vec![Severity::Warning, Severity::Error],
}