on master help sign in
Patch the primary cursor with insert and select styles
3606d8bwojciechkepka
helix-term/src/ui/editor.rs+14−2
@@ -282,16 +282,28 @@ impl EditorView {
282 Range::new(start, end)
282 Range::new(start, end)
283 };
283 };
284
284
285+ let mode = doc.mode();
285 let base_cursor_style = theme
286 let base_cursor_style = theme
286 .try_get("ui.cursor")
287 .try_get("ui.cursor")
287 .unwrap_or_else(|| Style::default().add_modifier(Modifier::REVERSED));
288 .unwrap_or_else(|| Style::default().add_modifier(Modifier::REVERSED));
288− let cursor_style = match doc.mode() {
289+ let cursor_style = match mode {
289 Mode::Insert => theme.try_get("ui.cursor.insert"),
290 Mode::Insert => theme.try_get("ui.cursor.insert"),
290 Mode::Select => theme.try_get("ui.cursor.select"),
291 Mode::Select => theme.try_get("ui.cursor.select"),
291 Mode::Normal => Some(base_cursor_style),
292 Mode::Normal => Some(base_cursor_style),
292 }
293 }
293 .unwrap_or(base_cursor_style);
294 .unwrap_or(base_cursor_style);
294− let primary_cursor_style = theme.try_get("ui.cursor.primary").unwrap_or(cursor_style);
295+ let primary_cursor_style = theme
296+ .try_get("ui.cursor.primary")
297+ .map(|style| {
298+ if mode != Mode::Normal {
299+ // we want to make sure that the insert and select highlights
300+ // also affect the primary cursor if set
301+ style.patch(cursor_style)
302+ } else {
303+ style
304+ }
305+ })
306+ .unwrap_or(cursor_style);
295
307
296 let selection_style = theme.get("ui.selection");
308 let selection_style = theme.get("ui.selection");
297 let primary_selection_style = theme
309 let primary_selection_style = theme