From 9dca2ee1c46303094413dd3755026da2436d4a43 Mon Sep 17 00:00:00 2001 From: Dreck Sallow Date: Sun, 27 Oct 2024 13:25:03 -0500 Subject: [PATCH] render cursorline only in editing area --- helix-term/src/ui/editor.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index f7541fe25..5e85d7a6a 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -99,7 +99,7 @@ pub fn render_view( let mut decorations = DecorationManager::default(); if is_focused && config.cursorline { - decorations.add_decoration(Self::cursorline(doc, view, theme)); + decorations.add_decoration(Self::cursorline(doc, view, inner, theme)); } if is_focused && config.cursorcolumn { @@ -773,7 +773,12 @@ pub fn render_diagnostics( } /// Apply the highlighting on the lines where a cursor is active - pub fn cursorline(doc: &Document, view: &View, theme: &Theme) -> impl Decoration { + pub fn cursorline( + doc: &Document, + view: &View, + inner_area: Rect, + theme: &Theme, + ) -> impl Decoration { let text = doc.text().slice(..); // TODO only highlight the visual line that contains the cursor instead of the full visual line let primary_line = doc.selection(view.id).primary().cursor_line(text); @@ -792,10 +797,9 @@ pub fn cursorline(doc: &Document, view: &View, theme: &Theme) -> impl Decoration let primary_style = theme.get("ui.cursorline.primary"); let secondary_style = theme.get("ui.cursorline.secondary"); - let viewport = view.area; move |renderer: &mut TextRenderer, pos: LinePos| { - let area = Rect::new(viewport.x, pos.visual_line, viewport.width, 1); + let area = Rect::new(inner_area.x, pos.visual_line, inner_area.width, 1); if primary_line == pos.doc_line { renderer.set_style(area, primary_style); } else if secondary_lines.binary_search(&pos.doc_line).is_ok() {