@@ -294,16 +294,27 @@ impl EditorView {
294294 });
295295
296296 let selection_style = theme.get("ui.selection");
297+ let primary_style = theme
298+ .try_get("ui.selection.primary")
299+ .unwrap_or(selection_style);
300+ let selection = doc.selection(view.id);
301+ let primary_idx = selection.primary_index();
297302
298− for selection in doc
299− .selection(view.id)
303+ for (i, selection) in selection
300304 .iter()
301− .filter(|range| range.overlaps(&screen))
305+ .enumerate()
306+ .filter(|(_, range)| range.overlaps(&screen))
302307 {
303308 // TODO: render also if only one of the ranges is in viewport
304309 let mut start = view.screen_coords_at_pos(doc, text, selection.anchor);
305310 let mut end = view.screen_coords_at_pos(doc, text, selection.head);
306311
312+ let style = if i != primary_idx {
313+ selection_style
314+ } else {
315+ primary_style
316+ };
317+
307318 let head = end;
308319
309320 if selection.head < selection.anchor {
@@ -331,7 +342,7 @@ impl EditorView {
331342 ),
332343 1,
333344 ),
334− selection_style,
345+ style,
335346 );
336347 } else {
337348 surface.set_style(
@@ -342,7 +353,7 @@ impl EditorView {
342353 viewport.width.saturating_sub(start.col as u16),
343354 1,
344355 ),
345− selection_style,
356+ style,
346357 );
347358 for i in start.row + 1..end.row {
348359 surface.set_style(
@@ -353,7 +364,7 @@ impl EditorView {
353364 viewport.width,
354365 1,
355366 ),
356− selection_style,
367+ style,
357368 );
358369 }
359370 surface.set_style(
@@ -363,7 +374,7 @@ impl EditorView {
363374 (end.col as u16).min(viewport.width),
364375 1,
365376 ),
366− selection_style,
377+ style,
367378 );
368379 }
369380