|
1 |
| -use std::borrow::Cow; |
2 |
| - |
3 | 1 | use helix_core::indent::IndentStyle;
|
4 |
| -use helix_core::{coords_at_pos, encoding, Position}; |
| 2 | +use helix_core::{coords_at_pos, encoding, unicode::width::UnicodeWidthStr, Position}; |
5 | 3 | use helix_lsp::lsp::DiagnosticSeverity;
|
6 | 4 | use helix_view::document::DEFAULT_LANGUAGE_NAME;
|
7 | 5 | use helix_view::{
|
@@ -169,18 +167,16 @@ where
|
169 | 167 | let visible = context.focused;
|
170 | 168 | let config = context.editor.config();
|
171 | 169 | let modenames = &config.statusline.mode;
|
| 170 | + let mode_str = match context.editor.mode() { |
| 171 | + Mode::Insert => &modenames.insert, |
| 172 | + Mode::Select => &modenames.select, |
| 173 | + Mode::Normal => &modenames.normal, |
| 174 | + }; |
172 | 175 | let content = if visible {
|
173 |
| - Cow::Owned(format!( |
174 |
| - " {} ", |
175 |
| - match context.editor.mode() { |
176 |
| - Mode::Insert => &modenames.insert, |
177 |
| - Mode::Select => &modenames.select, |
178 |
| - Mode::Normal => &modenames.normal, |
179 |
| - } |
180 |
| - )) |
| 176 | + format!(" {mode_str} ") |
181 | 177 | } else {
|
182 | 178 | // If not focused, explicitly leave an empty space instead of returning None.
|
183 |
| - Cow::Borrowed(" ") |
| 179 | + " ".repeat(mode_str.width() + 2) |
184 | 180 | };
|
185 | 181 | let style = if visible && config.color_modes {
|
186 | 182 | match context.editor.mode() {
|
|
0 commit comments