mirror of
https://github.com/helix-editor/helix.git
synced 2025-10-06 00:13:28 +02:00
statusline: dynamic padding for unfocused mode (#14440)
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use helix_core::indent::IndentStyle;
|
||||
use helix_core::{coords_at_pos, encoding, Position};
|
||||
use helix_core::{coords_at_pos, encoding, unicode::width::UnicodeWidthStr, Position};
|
||||
use helix_lsp::lsp::DiagnosticSeverity;
|
||||
use helix_view::document::DEFAULT_LANGUAGE_NAME;
|
||||
use helix_view::{
|
||||
@@ -169,18 +167,16 @@ where
|
||||
let visible = context.focused;
|
||||
let config = context.editor.config();
|
||||
let modenames = &config.statusline.mode;
|
||||
let mode_str = match context.editor.mode() {
|
||||
Mode::Insert => &modenames.insert,
|
||||
Mode::Select => &modenames.select,
|
||||
Mode::Normal => &modenames.normal,
|
||||
};
|
||||
let content = if visible {
|
||||
Cow::Owned(format!(
|
||||
" {} ",
|
||||
match context.editor.mode() {
|
||||
Mode::Insert => &modenames.insert,
|
||||
Mode::Select => &modenames.select,
|
||||
Mode::Normal => &modenames.normal,
|
||||
}
|
||||
))
|
||||
format!(" {mode_str} ")
|
||||
} else {
|
||||
// If not focused, explicitly leave an empty space instead of returning None.
|
||||
Cow::Borrowed(" ")
|
||||
" ".repeat(mode_str.width() + 2)
|
||||
};
|
||||
let style = if visible && config.color_modes {
|
||||
match context.editor.mode() {
|
||||
|
Reference in New Issue
Block a user