From c9af6d8b69815dc3c9801ae4d1bda098842b9d5b Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Thu, 3 Mar 2022 13:22:14 +0000 Subject: [PATCH] fix line counter y shift --- core/src/editor.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/editor.rs b/core/src/editor.rs index fd063a47..d2bbb1eb 100644 --- a/core/src/editor.rs +++ b/core/src/editor.rs @@ -1739,16 +1739,11 @@ fn paint_gutter(&self, ctx: &mut PaintCtx, gutter_width: f64) { current_line - line } }; - let x = ((last_line + 1).to_string().len() - - content.to_string().len()) as f64 - * width; - let y = line_height * line as f64 + 5.0 - scroll_offset.y; - let pos = Point::new(x, y); let content = content.to_string(); let text_layout = ctx .text() - .new_text_layout(content) + .new_text_layout(content.clone()) .font( self.config.editor.font_family(), self.config.editor.font_size as f64, @@ -1764,6 +1759,11 @@ fn paint_gutter(&self, ctx: &mut PaintCtx, gutter_width: f64) { }) .build() .unwrap(); + let x = ((last_line + 1).to_string().len() - content.len()) as f64 + * width; + let y = line_height * line as f64 - scroll_offset.y + + (line_height - text_layout.size().height) / 2.0; + let pos = Point::new(x, y); ctx.draw_text(&text_layout, pos); }