@@ -112,6 +112,10 @@ impl EditorView {
112112 }
113113 }
114114
115+ if editor.config().cursorline {
116+ Self::highlight_cursorline(doc, view, surface, theme);
117+ }
118+
115119 let highlights = Self::doc_syntax_highlights(doc, view.offset, inner.height, theme);
116120 let highlights = syntax::merge(highlights, Self::doc_diagnostics_highlights(doc, theme));
117121 let highlights: Box<dyn Iterator<Item = HighlightEvent>> = if is_focused {
@@ -686,6 +690,43 @@ impl EditorView {
686690 );
687691 }
688692
693+ /// Apply the highlighting on the lines where a cursor is active
694+ pub fn highlight_cursorline(doc: &Document, view: &View, surface: &mut Surface, theme: &Theme) {
695+ let text = doc.text().slice(..);
696+ let last_line = view.last_line(doc);
697+
698+ let primary_line = doc.selection(view.id).primary().cursor_line(text);
699+
700+ // The secondary_lines do contain the primary_line, it doesn't matter
701+ // as the else-if clause in the loop later won't test for the
702+ // secondary_lines if primary_line == line.
703+ // It's used inside a loop so the collect isn't needless:
704+ // https://github.com/rust-lang/rust-clippy/issues/6164
705+ #[allow(clippy::needless_collect)]
706+ let secondary_lines: Vec<_> = doc
707+ .selection(view.id)
708+ .iter()
709+ .map(|range| range.cursor_line(text))
710+ .collect();
711+
712+ let primary_style = theme.get("ui.cursorline.primary");
713+ let secondary_style = theme.get("ui.cursorline.secondary");
714+
715+ for line in view.offset.row..(last_line + 1) {
716+ let area = Rect::new(
717+ view.area.x,
718+ view.area.y + (line - view.offset.row) as u16,
719+ view.area.width,
720+ 1,
721+ );
722+ if primary_line == line {
723+ surface.set_style(area, primary_style);
724+ } else if secondary_lines.binary_search(&line).is_ok() {
725+ surface.set_style(area, secondary_style);
726+ }
727+ }
728+ }
729+
689730 pub fn render_statusline(
690731 &self,
691732 doc: &Document,